README 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. README (English)
  2. --------------------------------
  3. This directory contains unit tests and docs for Dolibarr quality analysis.
  4. - PHPUnit - https://phpunit.de
  5. - PHP_CodeSniffer - https://pear.php.net/package/PHP_CodeSniffer/
  6. - PHP Depend - https://pdepend.org/
  7. PHPUNIT
  8. -------
  9. To use make phpunit analysis, you must:
  10. * Install PHPUnit
  11. If using Eclipse, you must also add an entry as external tool for phpunit program with:
  12. -Name: PHPUnit
  13. -Location: Linux: /usr/bin/php
  14. Windows: C:\Program Files (x86)\wamp\bin\php\php5.2.8\php.exe
  15. -Workspace: ${workspace_loc}
  16. -Arguments: Linux: /usr/bin/phpunit ${resource_path}
  17. Windows: "C:\Program Files (x86)\PHPUnit-3.4.9\phpunit.php" ${resource_path}
  18. If not using Eclipse, to install PHPUnit manually:
  19. > sudo apt-get remove phpunit
  20. > sudo apt-get upgrade pear
  21. > sudo pear channel-discover pear.phpunit.de
  22. > sudo pear channel-discover pear.symfony-project.com
  23. > sudo pear channel-discover components.ez.no
  24. > sudo pear update-channels
  25. > sudo pear upgrade-all
  26. > sudo pear install --alldeps phpunit/PHPUnit
  27. * Run Unit tests:
  28. > cd test/phpunit
  29. > phpunit MyFileTest.php
  30. If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
  31. * Example to run phpunit 7.0 from composer using php version 8.0:
  32. > cd ~/tmp
  33. > composer -i phpunit
  34. > cd test/phpunit
  35. > /usr/bin/php8.0 ~/tmp/htdocs/includes/phpunit/phpunit/phpunit MyFileTest.php
  36. * Generate a report of Unit tests code coverage done by one tested class:
  37. > cd test
  38. > phpunit -d memory_limit=-1 -d max_input_time=1800 -d max_execution_time=1800 --configuration ./phpunit/phpunittest.xml --coverage-html ./report ./report/logs/phpunit.xml phpunit/MyClassTest.php
  39. Note that xdebug must be installed for this feature to work.
  40. * Generate a report of Unit tests code coverage done by all Dolibarr unit test classes:
  41. Increase your PHP memory (memory_limit and suhosin.memory_limit in php.ini) to 4G. You can check setup with "php -i | grep memory". Note: Version 3.5 need 1.5G
  42. > cd test
  43. > phpunit -d suhosin.memory_limit=4G -d memory_limit=-1 -d max_input_time=0 -d max_execution_time=0 --configuration ./phpunit/phpunittest.xml --coverage-html ./report phpunit/AllTests.php
  44. If there is a timeout before end, try this:
  45. > cd test
  46. > php -d suhosin.memory_limit=4G -d memory_limit=-1 -d max_input_time=0 -d max_execution_time=0 /usr/bin/phpunit -d suhosin.memory_limit=4G -d memory_limit=-1 -d max_input_time=0 -d max_execution_time=0 --configuration ./phpunit/phpunittest.xml --coverage-html ./report phpunit/AllTests.php
  47. ou
  48. > php -d suhosin.memory_limit=4G -d memory_limit=-1 -d max_input_time=0 -d max_execution_time=0 /usr/bin/phpunit -d suhosin.memory_limit=4G -d memory_limit=-1 -d max_input_time=0 -d max_execution_time=0 --configuration ./phpunit/phpunittest.xml --coverage-php ./report/codecoverage.php phpunit/AllTests.php
  49. puis
  50. > sudo renice -10 idprocessphp
  51. PHP-CODESNIFFER
  52. ---------------
  53. * Install phpcs
  54. * Launch PHP-Codesniffer:
  55. > cd dev
  56. > /usr/bin/php5 -c ./codesniffer/php.ini /usr/bin/phpcs --report=xml --standard=./codesniffer ../htdocs/test.php
  57. PHPDEPEND
  58. ---------
  59. * Install pdepend
  60. * Launch PDepend analysis:
  61. > cd test
  62. > pdepend --debug -d memory_limit=-1 --configuration=./phpunit/phpunittest.xml --phpunit-xml=./report/logs/pdepend.xml --summary-xml=./report/logs/summary.xml --jdepend-chart=./report/logs/jdepend.svg --overview-pyramid=./report/logs/pyramid.svg --ignore=custom,custom2,adodbtime,artichow,ckeditor,efc_xfss,fckeditor,fpdf,geoip,magpierss,nusoap,odtphp,php_writeexcel,smarty,smtps,tcpdf,vcard ../htdocs
  63. * To clean pdepend cache files
  64. > rm -fr ~/.pdepend/*