# Fix: Use accessible temporarypath for CMailFileTest
'/tmp' does not exist on all systems and is subject to open_basedir
restrictions. Selected another temporary path for the test.
* Fix: Use accessible path for CategorieTest
# Fix: Use accessible path for CategorieTest
The test was using '/' (root of the filesystem) which was outside
the open_basedir paths. Modified the path to the medias directory to allow the test to pass with open_basedir restriction in effect.
* Update CategorieTest.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
# Qual: Improve logging on phpunit error by limiting to new log lines
Log only the new files since the start of the failed test within the limit
of the number of requested lines.
To do this, the log file size is recorded in setUp() to show only the data
beyond this limit on error.
# Qual: Improve PhpUnit logging in case of error.
- Log exception message with extra log information.
- Do not output markers for dolibarr.log if no log lines should be shown.
- Use GitHub action style prefixes to group messages
# Fix: phpunit - Add adapter to "not existing directory" assertion
This is a helper function added to the common test class which is useful
to maintain cross phpunit version compatibility without triggering a
deprecation error for internal phpunit test functions.
Used in a testcase for dol_dir_move in a pending PR
* Fix: Replace deprecated module names in code strings
# Fix: Replace deprecated module names in code strings
A few cases that slipped through the manual replacements
* Qual: Enable deprecation notices in CodingPhpTest for isModEnabled
# Qual: Enable deprecation notices in CodingPhpTest for isModEnabled
As all detections are now fixed, we can enable the deprecation notice
trigger in the CodingPhpTest.
* Fix: Fix var_dump checker
# Fix: Fix var_dump checker
The core issue was that in PHP whitespace includes newlines by default, the m modifier
is needed to not match multilines.
* Fix: Allow multiple var_dumps on single comment line, refactor
# Fix: Allow multiple var_dumps on single comment line, refactor
Updated the regex to not match a var_dump preceeded with a comment
somewhere on the line.
Refactored var_dump check in dedicated method.
* Qual: Test the test function !
# Qual: Test the test function !
Test that the test function detecting var_dump does detect them.
* Qual: CodingPhpTest - remove comments from file before checking
# Qual: CodingPhpTest - remove comments from file before checking
This helps remove false positives and may have a positive impact on performance.
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Qual: CommonClassTest - less verbosity, but better when error
# Qual: CommonClassTest - less verbosity, but better when error
- Report the test method and parameters in case of error.
- Less verbosity about setup.
- $_ENV was empty array, replaced with getenv()
* Qual: Refactor CodingPhpTest
# Qual: Refactor CodingPhpTest
- Use dataprovider (better progress report, better errors, better continuation)
- Use dol_dir_list's exclude_filter capability (do not traverse the excluded dirs)
- Reduce debug output from dolibarr.log (not really relevant for these tests).
* Fix: References to loop variables outside loop
# Fix: References to loop variables outside loop
The test referenced some undefined variables outside foreach loops ($val[0])
* Update CommonClassTest.class.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Fix: Correct CommonClassTest's constructor
# Fix: Correct CommonClassTest's constructor
Dataproviders did not work because of the issue with the constructor
* Qual: Refactor module name list, add mapping to class name
# Qual: Refactor module name list, add mapping to class name
Based on ModuleTest and search for modules in the code, complete the
list of modules and map to the class names.
This will allow reuse in the ModuleTest.
* Qual: Refactor ModulesInit test
# Qual: Refactor ModulesInit test
Use the updated common module mapping list, more complete than
the original list.
Also refactor the test to use a data provider.
* Fix: valid module test must now use array_key_exists
# Fix: valid module test must now use array_key_exists
Because of the introduction of null key values, isset on the array no
longer works, using array_key_exists to test if the modulename is valid.
* fixup! Qual: Refactor module name list, add mapping to class name
* Qual: Less verbosity for tests
# Qual: Less verbosity for tests
The verbosity on setup/teardown/... is not really usefull and
makes the log less readable. Reducing the verbosity while allowing
to set an environment variable PHPUNIT_DEBUG to enable it.
* Qual: Add test to validate module_names
# Qual: Add test to validate module_names
This ensures that all explitly tested module names appear in the reference list.
Displays messages when the module_name is deprecated
* Update CodingPhpTest.php
* Update CodingPhpTest.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Fix: Workaround for false security issue in tests
# Fix: Workaround for false security issue in tests
This is a quick workaround for the false security issues in tests
by setting the ['SELF'] variable to something that is
considered harmless
* Update windows-ci workflow
# Update windows-ci workflow
- Setup_conf.sh - Added caching feature;
- phpunit.bat - Example updated based on experience with php web server
- Provide dolibarr.log and phpunit output as artefacts.
- Convert PHPUNIT log to Github Annotations
- Setup php web server for API tests
- Enable caching sql initialisation
* Qual: Re-enable open_basedir restriction in tests
# Qual: Re-enable open_basedir restriction in tests
Using open_basedir restriction is closer to the production reality
and seemed to generate some issues on a windows development machine.
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Fix: Deprecation message for backupGlobalsBlackList
# Fix: Deprecation message for backupGlobalsBlackList
Fix the deprecation messages during the tests:
1) AdminLibTest::testVersionCompare
PHPUnit\Framework\TestCase::$backupGlobalsBlacklist is deprecated and will be removed in PHPUnit 10. Please use PHPUnit\Framework\TestCase::$backupGlobalsExcludesList instead.
* Fix: Remove backupGlobalsBlacklist/backupGlobalsExcludesList
# Fix: Remove backupGlobalsBlacklist/backupGlobalsExcludesList
The backupGlobalsBlacklist/backupGlobalsExcludesList does not seem required
and it is not documented why it is required, so remove this to simplify
the code (see https://github.com/Dolibarr/dolibarr/pull/28292#discussion_r1495116364 ).
# Fix: Improve test configuration
## Do not fail early when running tests (stopOnFailure->false)
Finishing the phpunits tests does not require a lot of extra time
so rather than quiting early, run them all.
Also, when needed this option can be enabled on the CLI, but
it can not be disabled. So when desired, it can still be added
in a ci-flow or local script.
## Improve reporting
We want to report Notices and Warnings and with enough detail to
help during debug. These options are explicitly activated.
* Qual: Apply php-cs-fixer before changes
# Qual: Apply php-cs-fixer before changes
Apply php-cs-fixer before changes to make real changes stand out
in next commit.
* Qual: Improve test messages to help locate errors.
# Qual: Improve test messages to help locate errors.
Included a description of the test in the failing assertions to
help locate the error.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: Update spelling exception
# Qual: Update spelling exception
Formatting the code requires an update in the spelling exception list.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Qual: php-cs-fixer on phpunit test file
# Qual: php-cs-fixer on phpunit test file
Apply php-cs-fixer on phpunit test files so that future manual changes
stand out.
* Fix: Improve error messages for AdminLibTest
# Fix: Improve error messages for AdminLibTest
These changes clarify the messages when the changed assertions fail.
* Qual: Improve error messages for FileLibTest
# Qual: Improve error messages for FileLibTest
Certain tests now have error messages that help identify a failing test.
# SEC: #28168 Correct protocol limitations (PHP7.4/Win)
Protocol limitation was not active during test on windows platform.
Moving the application of the limitation just before the curl_exec
instruction made the limitation effective.
Also extended the code to enable allowing ftp and ftps and extended
the code for [CURLOPT_REDIR_PROTOCOLS_STR](https://www.php.net/manual/en/curl.constants.php#constant.curlopt-redir-protocols-str).
The files with exceptions can be updated as there are many less cases to
exclude.
In the project files there are a few minor spelling corrections, and
`$scrit` was changed to `$search_crit` to avoid a spelling suggestion.
* Qual: Spelling fixes that newly appeared.
# Qual: Fix spelling erros that appeared since the bulk updates.
These issues mostly appeared since the bulk updates (a few ones were postponed
to make sure no real spelling errors were missed.)
* Update modulebuilder.lib.php
* Update pdf_standard.modules.php
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
* Qual: Spelling outside htdocs
# Qual: Fix spelling of files not in the htdocs subdirectory.
Highlight:
- Change in email test from unvalid to invalid that should give the same test result.
* Update Dolibarr-soapui-project.xml
---------
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
Fix the following error when running without the dataset.
Fichinter
✘ Fichinter create
┐
├ ERROR: 23503: insert or update on table "llx_fichinter" violates foreign key constraint "fk_fichinter_fk_soc"
├ DETAIL: Key (fk_soc)=(1) is not present in table "llx_societe".
├ SCHEMA NAME: public
├ TABLE NAME: llx_fichinter
├ CONSTRAINT NAME: fk_fichinter_fk_soc
├ LOCATION: ri_ReportViolation, ri_triggers.c:2596,
├ Failed asserting that 0 is less than -1.
│
│ dolibarr/test/phpunit/FichinterTest.php:147
┴
Adding $localobject->errorsToString() as third argument to the assert
will allow to forward internal errors towards the tests and display them
accordingly.
The testContratCreate() is using the default value for Contrat::socid,
which is defined by Contrat::initAsSpecimen to `0`. But if no companies
have been created, the test will fail with the following error:
Failed asserting that 0 is less than -1.
Or with the additional logging:
UnknownError: ERROR: 23503: insert or update on table "llx_contrat" violates foreign key constraint "fk_contrat_fk_soc"
DETAIL: Key (fk_soc)=(1) is not present in table "llx_societe".
SCHEMA NAME: public
TABLE NAME: llx_contrat
CONSTRAINT NAME: fk_contrat_fk_soc
LOCATION: ri_ReportViolation, ri_triggers.c:2596 -,
Failed asserting that 0 is less than -1.
The test doesn't really depends on specific test data so we can create
the company directly instead.
The testCompanyBankAccountCreate() is using the default value for
CompanyBankAccount::socid, which is defined by
CompanyBankAccount::initAsSpecimen to `0`. But if no companies have been
created, the test will fail with the following error:
Failed asserting that 0 is less than -1.
Or with the additional logging:
ERROR: 23503: insert or update on table "llx_societe_rib" violates foreign key constraint "llx_societe_rib_fk_societe"
DETAIL: Key (fk_soc)=(1) is not present in table "llx_societe".
SCHEMA NAME: public
TABLE NAME: llx_societe_rib
CONSTRAINT NAME: llx_societe_rib_fk_societe
LOCATION: ri_ReportViolation, ri_triggers.c:2596, ERROR: 23503: insert or update on table "llx_societe_rib" violates foreign key constraint "llx_societe_rib_fk_societe"
DETAIL: Key (fk_soc)=(1) is not present in table "llx_societe".
SCHEMA NAME: public
TABLE NAME: llx_societe_rib
CONSTRAINT NAME: llx_societe_rib_fk_societe
LOCATION: ri_ReportViolation, ri_triggers.c:2596
Failed asserting that 0 is less than -1.
The test doesn't really depends on specific test data so we can create
the company directly instead.
The testCommandeCreate() is using the default value for Commande::socid,
which is defined by Command::initAsSpecimen to `0`. But if no companies
have been created, the test will fail with the following error:
Failed asserting that 0 is less than -1.
Or with the additional logging:
ERROR: 23503: insert or update on table "llx_commande" violates foreign key constraint "fk_commande_fk_soc"
DETAIL: Key (fk_soc)=(1) is not present in table "llx_societe".
SCHEMA NAME: public
TABLE NAME: llx_commande
CONSTRAINT NAME: fk_commande_fk_soc
LOCATION: ri_ReportViolation, ri_triggers.c:2596,
Failed asserting that 0 is less than -1.
The test doesn't really depends on specific test data so we can create
the company directly instead.
* 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 from deb91ad7c1.
* societe: remove fields from property copy
$phone_pro and $fk_project are not existing for societe. This was added
from deb91ad7c1.
* 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>
* reception: reOpen: mirror $this->statut in $this->status
$this->statut is the deprecated variable, $this->status should also get
the correct value.
* reception: setDraft: mirror $this->statut in $this->status
$this->statut is the deprecated variable, $this->status should also get
the correct value.
* reception: add missing $weight field
Fix warning:
Undefined property: Reception::$weight
* societe: add country_id field
* reception: use getDolGlobalInt when suitable
Using empty() implies that the value actually exists on the stdClass at
$conf->global, but it's not always the case. getDolGlobalInt will handle
this smoothly by checking first, which solves warnings like those:
Undefined property: stdClass::$STOCK_CALCULATE_ON_RECEPTION
* ReceptionTest: add new test
The test checks the usual workflow of the Reception class, with, on the
one hand, the common CRUD operations:
- create
- fetch
- update
- delete
And on the other hand, the status handling for Reception:
- valid: STATUS_DRAFT -> STATUS_VALID
- setClosed: STATUS_VALID -> STATUS_CLOSED
- reOpen: STATUS_CLOSED -> STATUS_VALID
- setDraft: STATUS_VALID -> STATUS_DRAFT
The stocks lines are not tested yet, and the error cases, like any other
transition not described above, are not tested either. The permissions
for some of the operations are hardcoded for the test and there is no
failure check when the permission is not set yet.
Fix the following errors when running recent phpunit:
Message: Too few arguments to function PHPUnit\Framework\TestCase::__construct(), 0 passed in
dolibarr/test/phpunit/DateLibTzFranceTest.php on line 63 and exactly
1 expected Location: phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php:265
Indeed, the old constructor had an optional $name='' parameter but the
new constructor reads like this:
public function __construct(string $name)
and the parameter is now mandatory.
PHP Fatal error: Declaration of ODFTest::setUpBeforeClass() must be
compatible with PHPUnit\Framework\TestCase::setUpBeforeClass(): void
in dolibarr/test/phpunit/ODFTest.php on line 82
The test class was copied from InventoryTest and phpunit is now
complaining that it cannot find the class in the test.
1) Class EvalMathTest cannot be found in phpunit/EvalMathTest.php
(phpunit 10.0.7)
Commit cfff62c2fa removed $conf->syslog
usage, but this file was left of as-is.
Fix a warning on the test:
Files Lib
✔ Dol basename
✔ Dol count nb of line
✔ Dol is file dir
✔ Dol other
✔ Dol mime type
✔ Dol delete dir
✔ Dol copy move delete
✘ Dol compress un compress
┐
├ Error: Attempt to assign property "enabled" on null
│
│ /home/alexandre/workspace/dolibarr/test/phpunit/FilesLibTest.php:421
┴
✔ Dol check secure access document
✔ Dol dir move
The global variables are stored in $this, and in particular $db is used
through this mean. But $this->savdb is supposed to be the immutable
global state that is stored at the test class instantiation and restored
at the beginning of each test.
For $this->savdb, I don't think any consequences are created by this,
since the object is saved by each test anyway and the $db object is
mostly a query object within a transaction, but future change could use
this to inject a different stateful $db object to trace some behaviour
in the test for instance, so make sure the correct one is used.