# Fix: Script tests (on Windows)
- Set `exit(255)` instead of `exit(-1)` in `scripts/bank/export-bank-receipts.php`.
On *nix, the -1 converts into an exist code of 255 but on windows it
is -1, making the test fail.
- Add a helper method to execute php scripts using the php binary used
to run phpunit.
Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
# Qual: FactureTest - use assertions rather than dying in the setup.
The 'die()' instructions have been replaced - not all tests should fail
because the preconditions for a test case are not met.
# Fix: Skip UtilsTest on windows where ls is not available
The test in question uses 'ls' which is not available on windows.
This change limits the execution to non windows systems.
# 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.