dolibarr/test/README

87 lines
3.6 KiB
Plaintext
Raw Permalink Normal View History

2010-04-25 16:19:58 +02:00
README (English)
--------------------------------
2012-08-05 13:30:12 +02:00
This directory contains unit tests and docs for Dolibarr quality analysis.
2010-05-06 00:41:54 +02:00
2020-02-25 14:04:54 +01:00
- PHPUnit - https://phpunit.de
- PHP_CodeSniffer - https://pear.php.net/package/PHP_CodeSniffer/
- PHP Depend - https://pdepend.org/
2010-05-06 00:41:54 +02:00
PHPUNIT
-------
2011-02-13 19:08:53 +01:00
To use make phpunit analysis, you must:
2010-04-25 16:25:44 +02:00
2010-04-25 16:19:58 +02:00
* Install PHPUnit
2019-02-10 12:59:09 +01:00
If using Eclipse, you must also add an entry as external tool for phpunit program with:
2010-04-25 16:19:58 +02:00
-Name: PHPUnit
2010-04-27 01:20:14 +02:00
-Location: Linux: /usr/bin/php
Windows: C:\Program Files (x86)\wamp\bin\php\php5.2.8\php.exe
2010-04-25 16:19:58 +02:00
-Workspace: ${workspace_loc}
2010-04-27 01:20:14 +02:00
-Arguments: Linux: /usr/bin/phpunit ${resource_path}
Windows: "C:\Program Files (x86)\PHPUnit-3.4.9\phpunit.php" ${resource_path}
2012-08-05 13:30:12 +02:00
If not using Eclipse, to install PHPUnit manually:
> sudo apt-get remove phpunit
> sudo apt-get upgrade pear
> sudo pear channel-discover pear.phpunit.de
> sudo pear channel-discover pear.symfony-project.com
> sudo pear channel-discover components.ez.no
> sudo pear update-channels
> sudo pear upgrade-all
> sudo pear install --alldeps phpunit/PHPUnit
2010-04-25 16:25:44 +02:00
2021-08-17 14:12:57 +02:00
2010-04-27 01:20:14 +02:00
* Run Unit tests:
2014-03-15 12:23:46 +01:00
> cd test/phpunit
2011-02-13 11:25:13 +01:00
> phpunit MyFileTest.php
2010-04-25 16:25:44 +02:00
If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
2010-04-25 16:48:12 +02:00
2021-08-17 14:12:57 +02:00
* Example to run phpunit 7.0 from composer using php version 8.0:
> cd ~/tmp
> composer -i phpunit
> cd test/phpunit
> /usr/bin/php8.0 ~/tmp/htdocs/includes/phpunit/phpunit/phpunit MyFileTest.php
2015-04-04 02:44:42 +02:00
* Generate a report of Unit tests code coverage done by one tested class:
2011-02-13 11:25:13 +01:00
> cd test
2015-04-04 02:44:42 +02:00
> 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
2010-04-25 16:48:12 +02:00
Note that xdebug must be installed for this feature to work.
2010-04-27 01:20:14 +02:00
2015-04-04 02:44:42 +02:00
* Generate a report of Unit tests code coverage done by all Dolibarr unit test classes:
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
2011-02-13 11:25:13 +01:00
> cd test
> 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
2011-07-09 01:35:05 +02:00
2011-07-09 02:11:55 +02:00
If there is a timeout before end, try this:
2011-07-09 01:35:05 +02:00
> cd test
2013-09-09 03:23:56 +02:00
> 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
ou
> 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
2015-04-04 02:44:42 +02:00
puis
> sudo renice -10 idprocessphp
2011-07-09 01:35:05 +02:00
PHP-CODESNIFFER
---------------
* Install phpcs
* Launch PHP-Codesniffer:
> cd dev
2011-07-09 02:11:55 +02:00
> /usr/bin/php5 -c ./codesniffer/php.ini /usr/bin/phpcs --report=xml --standard=./codesniffer ../htdocs/test.php
2010-04-27 11:05:42 +02:00
2010-05-06 00:41:54 +02:00
PHPDEPEND
---------
2011-07-09 01:35:05 +02:00
* Install pdepend
2010-05-06 00:41:54 +02:00
2011-02-13 11:25:13 +01:00
* Launch PDepend analysis:
> cd test
2020-12-13 16:27:44 +01:00
> 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
2011-02-13 19:42:36 +01:00
* To clean pdepend cache files
> rm -fr ~/.pdepend/*