mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
* societe: add missing model_pdf field The field is used by the class but wasn't declared. * societe: expose Societe::mergeCompany The code is directly copied from societe/card.php with as less changes as possible. The original code came fromdeb91ad7c1. * societe: remove fields from property copy $phone_pro and $fk_project are not existing for societe. This was added fromdeb91ad7c1. * SocieteTest: test the merge functionality This test is a simple smoke test to check that the mergeCompany() will work correctly on simple case and actually merge the details of the company. More complex deduplication pattern with objects referencing the deleted Societe object, will be written for each of the different object class in their respective test file. * societe: card: use the new mergeCompany function Since the code is almost the same, there should be no differences in behaviour right now. * societe: api_thirdparties: use Societe::mergeCompany() * societe: fix issue when merging companies When a Societe object is merged against another, its related objects are supposed to reference the new Societe object so that the databse doesn't raise foreign key errors. The list references the objects that need to be transformed, and Reception objects weren't part of this list. Fix #26272 * ReceptionTest: check company merge hook Before a Societe object is destroyed from the database, every object referencing the FK should be destroyed or should reference another object. In the case of two companies being merged, the case arises and Reception objects need to be moved to the new company. This commit brings a non-regression test for this case. Refs #26272 * Update societe.class.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
README (English)
--------------------------------
This directory contains unit tests and docs for Dolibarr quality analysis.
- PHPUnit - https://phpunit.de
- PHP_CodeSniffer - https://pear.php.net/package/PHP_CodeSniffer/
- PHP Depend - https://pdepend.org/
PHPUNIT
-------
To use make phpunit analysis, you must:
* Install PHPUnit
If using Eclipse, you must also add an entry as external tool for phpunit program with:
-Name: PHPUnit
-Location: Linux: /usr/bin/php
Windows: C:\Program Files (x86)\wamp\bin\php\php5.2.8\php.exe
-Workspace: ${workspace_loc}
-Arguments: Linux: /usr/bin/phpunit ${resource_path}
Windows: "C:\Program Files (x86)\PHPUnit-3.4.9\phpunit.php" ${resource_path}
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
* Run Unit tests:
> cd test/phpunit
> phpunit MyFileTest.php
If using Eclipse, select the test and click on menu "Run external tools and choose PHPUnit".
* 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
* Generate a report of Unit tests code coverage done by one tested class:
> cd test
> 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
Note that xdebug must be installed for this feature to work.
* 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
> 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
If there is a timeout before end, try this:
> cd test
> 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
puis
> sudo renice -10 idprocessphp
PHP-CODESNIFFER
---------------
* Install phpcs
* Launch PHP-Codesniffer:
> cd dev
> /usr/bin/php5 -c ./codesniffer/php.ini /usr/bin/phpcs --report=xml --standard=./codesniffer ../htdocs/test.php
PHPDEPEND
---------
* Install pdepend
* Launch PDepend analysis:
> cd test
> 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
* To clean pdepend cache files
> rm -fr ~/.pdepend/*