README 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. README (English)
  2. --------------------------------
  3. This directory contains unit tests and docs for Dolibarr quality analysis.
  4. PHPUNIT
  5. -------
  6. To use make phpunit analysis, you must:
  7. * Install PHPUnit
  8. If using Eclipse, you must also add an entry as external tool for phpunit programm with:
  9. -Name: PHPUnit
  10. -Location: Linux: /usr/bin/php
  11. Windows: C:\Program Files (x86)\wamp\bin\php\php5.2.8\php.exe
  12. -Workspace: ${workspace_loc}
  13. -Arguments: Linux: /usr/bin/phpunit ${resource_path}
  14. Windows: "C:\Program Files (x86)\PHPUnit-3.4.9\phpunit.php" ${resource_path}
  15. If not using Eclipse, to install PHPUnit manually:
  16. > sudo apt-get remove phpunit
  17. > sudo apt-get upgrade pear
  18. > sudo pear channel-discover pear.phpunit.de
  19. > sudo pear channel-discover pear.symfony-project.com
  20. > sudo pear channel-discover components.ez.no
  21. > sudo pear update-channels
  22. > sudo pear upgrade-all
  23. > sudo pear install --alldeps phpunit/PHPUnit
  24. * Run Unit tests:
  25. > cd test/phpunit
  26. > phpunit MyFileTest.php
  27. If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
  28. * Generate a report of Unit tests code coverage done by one tested class:
  29. > cd test
  30. > 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
  31. Note that xdebug must be installed for this feature to work.
  32. * Generate a report of Unit tests code coverage done by all Dolibarr unit test classes:
  33. 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
  34. > cd test
  35. > 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
  36. If there is a timeout before end, try this:
  37. > cd test
  38. > 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
  39. ou
  40. > 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
  41. puis
  42. > sudo renice -10 idprocessphp
  43. PHP-CODESNIFFER
  44. ---------------
  45. * Install phpcs
  46. * Launch PHP-Codesniffer:
  47. > cd dev
  48. > /usr/bin/php5 -c ./codesniffer/php.ini /usr/bin/phpcs --report=xml --standard=./codesniffer ../htdocs/test.php
  49. PHPDEPEND
  50. ---------
  51. * Install pdepend
  52. * Launch PDepend analysis:
  53. > cd test
  54. > 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,phpexcel,php_writeexcel,smarty,smtps,tcpdf,vcard ../htdocs
  55. * To clean pdepend cache files
  56. > rm -fr ~/.pdepend/*