Commit Graph

1955 Commits

Author SHA1 Message Date
Laurent Destailleur
1b2bad3f42 NEW Add function to manipulate emojis 2024-05-14 18:19:48 +02:00
Laurent Destailleur
7f3ed10922 Add phpunit case 2024-05-14 04:08:54 +02:00
Laurent Destailleur
27bc1cddad Debug v20 2024-05-08 15:43:46 +02:00
Laurent Destailleur
f8d072f04c Fix phpunit 2024-04-23 20:26:24 +02:00
MDW
31584659e0
Refactor objCompare
# Refactor objCompare:

- Move to CommonClassTest;
- Report class name for mismatched property;
- Cope with dolDeprecated property aliases (test may exclude deprecated name,
  also exclude new name).
2024-04-02 11:25:17 +02:00
Laurent Destailleur
fbf0912a98 Fix phpunit warnings 2024-03-28 21:33:09 +01:00
Laurent Destailleur
0544670ac4
Merge pull request #28160 from mdeweerd/core/deprecationclass
NEW: DolDeprecationHandler for deprecations
2024-03-28 12:42:53 +01:00
MDW
c87c3b100c
Qual: LangTest: Use dataprovider, beautify output 2024-03-27 22:12:27 +01:00
Laurent Destailleur
4efa503400 NEW Accept the __NOW__ and __USER_ID__key into filters 2024-03-25 23:53:28 +01:00
MDW
a6d4a99cca
NEW: DolDeprecationHandler for deprecations
# NEW: DolDeprecationHandler for deprecations

This reusable class avoids needed to implement double assignments while enabling
the detection of the use of deprecated variables and methods.

There is no efficiency overhead when the proper variables and methods are
used.
2024-03-24 17:39:02 +01:00
Laurent Destailleur
295587ea20 Fix warning 2024-03-24 14:19:44 +01:00
Laurent Destailleur
220b9d0852 Add a unit test on dol_eval 2024-03-24 07:08:40 +01:00
Laurent Destailleur
3fdf5e2881 Fix phpunit for Expedition 2024-03-24 06:31:59 +01:00
Laurent Destailleur
954b127ee0 Fix phpunit 2024-03-24 06:30:18 +01:00
Laurent Destailleur
072c3070b3 Add phpunit for Expedition 2024-03-24 06:23:56 +01:00
Laurent Destailleur
d9488770ae GETPOST(..., 'alpha') does not accept \ char anymore. Replaced with / 2024-03-24 01:45:31 +01:00
Laurent Destailleur
7cbff76f9d Fix phpunit 2024-03-21 14:48:03 +01:00
Laurent Destailleur
2d0e57ce7c Fix test for pgsql 2024-03-21 14:13:17 +01:00
Laurent Destailleur
aa77573cd9 Sanitize DDL instructions 2024-03-21 12:45:58 +01:00
Laurent Destailleur
171c32be34 Add DDLDropTable and DDLCreateTable into phpunit tests 2024-03-21 12:21:38 +01:00
Laurent Destailleur
ae10eedf2a Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-21 11:29:16 +01:00
Laurent Destailleur
57eb393dad Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2024-03-21 11:22:28 +01:00
Andrés Maldonado
976686262d FIX: SQL syntax error in DDLUpdateField 2024-03-21 02:36:40 +01:00
MDW
a094ad38fc
Fix spelling (using beta codespell)
# Fix spelling (using beta codespell

New spelling fixes - ignoring thirdparty which should be either third-party
or third party.
2024-03-20 00:35:01 +01:00
MDW
f2b7179392
Add test case for numero_semaine 2024-03-18 04:03:50 +01:00
MDW
e5cf5475a1
Qual: Improve test message on failure 2024-03-15 14:20:59 +01:00
MDW
d8a785fa2b
FIX get_string_between
# FIX get_string_between

Noticed that the typing of the arguments was incorrect and then found
the implementation suspicious.  The implemented test confirmed that it
was flawed.  Fixed.

Apparently this method is used in get_next_value .
2024-03-13 02:58:59 +01:00
Laurent Destailleur
a6926c29c0
Merge pull request #28778 from fappels/develop_fix_delivery_note
Fix shipping is not a delivery_note (is sub module of shipping)
2024-03-12 14:53:51 +01:00
Francis Appels
75e99a6dee Fix phan tool for shipping 2024-03-12 11:21:42 +01:00
MDW
325cb587f6
Qual: Exclude some tests from windows-ci until fixed
# Qual: Exclude some tests from windows-ci until fixed

Until #28598 and #28264 find some way to the develop branch, this update will
skip the tests that currently fail on windows so that the results of other
tests have an effect on the CI status and github annotations
2024-03-11 20:46:21 +01:00
Laurent Destailleur
1aa1647606
Update SecurityTest.php 2024-03-11 12:53:03 +01:00
Laurent Destailleur
41a57c05c5
Update SecurityTest.php 2024-03-11 12:51:27 +01:00
Laurent Destailleur
29216f3d4e
Update CommonClassTest.class.php 2024-03-11 12:49:15 +01:00
Laurent Destailleur
ff0d147847
Merge branch 'develop' into test/security_dol_eval_ob_cleanup_on_exception 2024-03-11 12:48:31 +01:00
Laurent Destailleur
1f4e7aedde Avoid to denaturate value when not required. 2024-03-11 12:47:53 +01:00
MDW
101d56a2c1
Fix: Ob buffer cleanup on exception
# Fix: Ob buffer cleanup on exception

The OB buffer capture was incorrectly cleaned up on exception.
This fixes that.

Also modified the SecurityTest to enable running it standalone
2024-03-10 15:17:58 +01:00
MDW
746ca01423
Fix: Correctly close active output buffer. (#28723)
# Fix: Correctly close active output buffer.

Use ob_get_clean(), not ob_get_contents() and ob_clean().

Tests were failing with:
FunctionsLibTest::testVerifCond with data set "Test that verifConf("0") returns false" ('0', false)
Test code or tested code did not (only) close its own output buffers

OK, but incomplete, skipped, or risky tests\!

Also refactored a test case to use a data provider which helped identify that it was related
to dol_eval.
2024-03-09 01:27:01 +01:00
Laurent Destailleur
f0693549b3 Fix bad message 2024-03-05 01:12:28 +01:00
Laurent Destailleur
41c8c23dbb Disable not complete test 2024-03-05 01:07:19 +01:00
Laurent Destailleur
31ae1bf97f Fix restore stop on failure. No need to continue, we must fix first.
Make travis error analysis easier too.
2024-03-05 01:05:50 +01:00
Laurent Destailleur
d09c9c0174 Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-05 00:23:38 +01:00
Laurent Destailleur
ce010a54c7 Clean code and prepare a more powerfull phpunit check for sql forging. 2024-03-05 00:22:12 +01:00
MDW
6f8b941c96
Fix: Script tests on Windows where PHP executable is not in path. (#28565)
# 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>
2024-03-04 20:13:34 +01:00
Laurent Destailleur
53e47df053 Use new return code rule 2024-03-04 20:05:18 +01:00
Laurent Destailleur
301bec664a Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
2024-03-03 19:59:34 +01:00
Laurent Destailleur
1e00cf34d4 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into 19.0 2024-03-03 19:50:22 +01:00
Laurent Destailleur
17ff0972ab Fix use of invoke into computed fields 2024-03-03 19:35:37 +01:00
Laurent Destailleur
7b897ae27d Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-03 18:41:49 +01:00
MDW
e2fba5d03f
Qual: FactureTest - use assertions rather than dying in the setup. (#28585)
# 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.
2024-03-03 17:08:57 +01:00
MDW
faf00c35e3
Fix: Skip UtilsTest on windows where ls is not available (#28601)
# 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.
2024-03-03 17:01:17 +01:00
Laurent Destailleur
40f98d529e Fix phpcs 2024-03-03 16:58:03 +01:00
MDW
9c3a375839
Fix: Use accessible temporarypath for CMailFileTest (#28599)
# 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.
2024-03-03 16:56:12 +01:00
MDW
71bb3a1275
Fix: Use accessible path for CategorieTest (#28600)
* 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>
2024-03-03 15:59:08 +01:00
Laurent Destailleur
21feee3bc8 FIX Better test on validity of compute field syntax with parenthesis 2024-03-03 13:11:54 +01:00
Laurent Destailleur
e12c235185 Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2024-03-02 16:52:44 +01:00
MDW
9fc7749b96
Qual: Show exception type in error detail on phpunit error (#28576)
# Qual: Show exception type in error detail on phpunit error

Knowing the exception type can be helpful - it's not reported in the
summary.
2024-03-02 16:38:53 +01:00
Frédéric FRANCE
fba15178eb
all initAsSpecimen return int (#28577)
* all initAsSpecimen return int

* all initAsSpecimen return int

* all initAsSpecimen return int
2024-03-02 16:38:35 +01:00
Laurent Destailleur
2044a133e9 Fix warning 2024-03-02 13:15:20 +01:00
MDW
2a52a35dc1
Qual: Improve logging on phpunit error by limiting to new log lines (#28575)
# 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.
2024-03-02 12:42:20 +01:00
MDW
7e8b45f287
Qual: Improve PhpUnit logging in case of error. (#28562)
# 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
2024-03-01 20:39:52 +01:00
MDW
57f4fc14d8
Fix: phpunit - Add adapter to "not existing directory" assertion (#28534)
# 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
2024-03-01 12:50:51 +01:00
Laurent Destailleur
b62222c7e4 Fix bad const 2024-02-29 16:51:17 +01:00
MDW
c332251816
Fix: Replace deprecated module names in code strings (#28462)
* 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.
2024-02-28 23:01:01 +01:00
MDW
1b4a1510ec
Modify module mapping principle (#28511) 2024-02-28 22:47:28 +01:00
MDW
cec3a6c8e8
Qual: Add AbstractRestApiTest class, refactor RestApiUserTest, add RestApiMosTest (#28484)
* New: AbstractRestAPITest class

* Qual: Create RestAPIMosTest
2024-02-28 17:03:53 +01:00
MDW
acd8168cb6
Fix: Fix var_dump checker (#28226)
* 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>
2024-02-25 22:08:07 +01:00
Laurent Destailleur
a3c0c1958e Fix EOL in log 2024-02-24 18:05:42 +01:00
MDW
8842f8ab10
Qual: Refactor CodingPhpTest / CommonClassTest - less verbosity, but better when error (#28388)
* 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>
2024-02-24 14:12:32 +01:00
MDW
f3a3de8ea2
Qual: Fix/complete/refactor ModuleTest case. (#28373)
* 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.
2024-02-23 17:43:18 +01:00
MDW
f1f516f54c
NEW: Global constant for deprecated module mapping (#28348)
* Qual: Add another deprecated module mapping

* NEW: Global constant for deprecated module mapping
2024-02-22 13:23:39 +01:00
MDW
d5d7003f08
Qual: Add test to validate module_names (#28340)
* 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>
2024-02-22 02:54:37 +01:00
MDW
af01b3d73a
Qual: Re-enable open_basedir restriction in tests (#28315)
* 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>
2024-02-21 13:57:05 +01:00
Laurent Destailleur
4acf87f43d Fix warning 2024-02-21 12:46:20 +01:00
Laurent Destailleur
f66b8987ec Sync transifex 2024-02-21 12:40:11 +01:00
Laurent Destailleur
9294662bb5 QUAL Check lang files does not contains 'notranslate' 2024-02-21 12:21:44 +01:00
Laurent Destailleur
7dd9a448cb Fix lang files and add phpunit test to avoid bad < 2024-02-20 22:53:59 +01:00
Laurent Destailleur
02e9ef8023 Close #28293 2024-02-20 14:58:46 +01:00
MDW
db9ce13849
Test/adminlib/remove deprecation (#28302)
* 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 ).
2024-02-20 10:38:27 +01:00
MDW
272e8f79c9
Fix: Improve test configuration (#28294)
# 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.
2024-02-20 01:26:25 +01:00
Laurent Destailleur
626edcac77 Add phpunit test on tasks 2024-02-20 01:17:00 +01:00
MDW
afe17928f2
Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272)
* 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.
2024-02-19 15:28:21 +01:00
Laurent Destailleur
8abe663d6f Add phpunit to test the rename/move into a corrupted pdf file. 2024-02-17 18:59:57 +01:00
Laurent Destailleur
3d98b7b1ac Fix phpunit 2024-02-17 17:38:10 +01:00
Laurent Destailleur
750e3270ac Enhance apstats 2024-02-17 16:46:06 +01:00
Laurent Destailleur
c0a094974a Clean code 2024-02-17 16:03:24 +01:00
Laurent Destailleur
a3b876e5ca Clean code 2024-02-17 15:50:51 +01:00
Laurent Destailleur
eccff949d6 Mutualize code 2024-02-17 15:34:19 +01:00
Laurent Destailleur
671257e8e3 Clean phpunit tests 2024-02-17 15:19:06 +01:00
Laurent Destailleur
4bfbbff447 Remove teardownafter, setup and teardown method in phpunit test 2024-02-17 04:12:42 +01:00
Laurent Destailleur
f9f549ef26 Work on generic filter 2024-02-17 04:07:34 +01:00
Laurent Destailleur
56b0c29d1f Mutualise code 2024-02-16 23:26:32 +01:00
Laurent Destailleur
a32831bc6f Fix regression 2024-02-16 18:18:30 +01:00
Laurent Destailleur
6e8786241c Fix regression 2024-02-16 18:18:17 +01:00
MDW
399f5d6cbe
Qual Improve messages in tests (#28193)
* 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.
2024-02-16 02:28:32 +01:00
Laurent Destailleur
b48455c9d7 Can remove filter entries 2024-02-16 01:50:03 +01:00
Laurent Destailleur
7107b5feb3 Debug custom report filter management 2024-02-16 01:19:53 +01:00
MDW
43967a83a3
SEC: #28168 Correct protocol limitations (PHP7.4/Win) (#28172)
# 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).
2024-02-15 15:20:21 +01:00
Laurent Destailleur
eedb7e4ec3 Fix warning 2024-02-13 14:05:29 +01:00
Laurent Destailleur
77e836c1b9 Fix remove a test that has no sense 2024-02-11 12:25:21 +01:00
Laurent Destailleur
9abdc1229a Fix test to execute workflow actions. Add more info in trigger errors. 2024-02-10 21:25:26 +01:00
MDW
2e254892ea
Qual: Clean up codespell exceptions (#28104)
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.
2024-02-10 17:27:36 +01:00
Laurent Destailleur
1d6cbe1fda Fix GETPOST use should be avoid in classes 2024-02-02 23:46:12 +01:00
Laurent Destailleur
32e205b5d1 Clean code 2024-02-02 19:50:43 +01:00
thibdrev
bb2ca75c46
qual: Update FunctionsLibTest.php - add unit test for roundUpToNextMultiple()
see remarks from PR 27865
2024-01-30 17:49:58 +01:00
thibdrev
ec3687528e
qual: Update ProfidLibTest.php - uncomment line testing that BE TIN shall start by 0 or 1
Since PR#27829 has been merged, we can now uncomment the line testing that a the Belgium Tax Identification Number shall start by 0 or 1.
2024-01-28 17:11:12 +01:00
thibdrev
e0b35d2f6b
typo 2024-01-27 23:24:01 +01:00
thibdrev
4946184648
phpcs 2024-01-27 14:15:16 +01:00
thibdrev
1d0a6411bc
qual: add phpunit tests for profid.lib.php 2024-01-27 14:09:04 +01:00
Laurent Destailleur
e74ed60d0c Try to merge phpstan.neon and phpstan_action.neon 2024-01-14 13:14:52 +01:00
MDW
a04f2bf4e7
Qual: Spelling fixes that newly appeared. (#27495)
* 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>
2024-01-14 12:26:37 +01:00
Laurent Destailleur
8f9d104ccd Fix phpunit 2024-01-13 19:37:06 +01:00
MDW
42a0d05b63
Qual: Spelling outside htdocs (#27448)
* 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>
2024-01-12 17:14:13 +01:00
MDW
417726f7b1
Fix: Disable execute bit in git + correct shebangs (#27450)
# Fix: Execute bits in git and shebangs

Some files had the execute bit improperly set to enabled.
Some scripts did not have a correct shebang.
2024-01-12 17:10:16 +01:00
Laurent Destailleur
c15627016a Fix bad test for disabling TCPDI. Add more phpunit 2024-01-10 21:51:32 +01:00
MDW
c41029d2d4
Fix: Invalid package.json (#27391)
# Fix: extra comma in package.json making it invalid

Remove the comma to make the file valid.
2024-01-10 16:25:48 +01:00
Laurent Destailleur
41516716d5 Fix duplicate example 2024-01-10 15:23:45 +01:00
MDW
96c469a45d spelling/dolibarr 2024-01-10 12:59:49 +01:00
Alexandre Janniaux
a0a3339eb9 DiscountTest: fix create when no societe exists
Fix the following error when running without the dataset.

    ✘ Discount create
    ┐
    ├ ERROR:  23503: insert or update on table "llx_societe_remise_except" violates foreign key constraint "fk_soc_remise_fk_soc"                                                                                                                                                                                                                                                                                                                                      
    ├ DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                                                                                                                                                                                                                                                                                                                                                                                 
    ├ SCHEMA NAME:  public                                                                                                                                                                                                                                                                                                                                                                                                                                             
    ├ TABLE NAME:  llx_societe_remise_except                                                                                                                                                                                                                                                                                                                                                                                                                           
    ├ CONSTRAINT NAME:  fk_soc_remise_fk_soc                                                                                                                                                                                                                                                                                                                                                                                                                           
    ├ LOCATION:  ri_ReportViolation, ri_triggers.c:2596 - sql=INSERT INTO llx_societe_remise_except (entity, datec, fk_soc, discount_type, fk_user, description, amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code, multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc, fk_facture_source, fk_invoice_supplier_source) VALUES (1, '2024-01-05 14:05:20', 1, 0, 1, 'Specimen discount', 10, 1.96, 11.96, 19.6, '', 0, 0, 0,  null, null),
    ├ Failed asserting that 0 is less than -1.                                                                                                                                                                                                                                                                                                                                                                                                                         
    │
    │ dolibarr/test/phpunit/DiscountTest.php:147
    ┴
2024-01-05 15:05:33 +01:00
Laurent Destailleur
bbf687da0c Fix warning 2024-01-05 03:08:16 +01:00
Laurent Destailleur
02183b473d
Merge pull request #27294 from alexandre-janniaux/fichintertest-soc/1
FIX: FichinterTest: create Societe object in test
2024-01-05 02:05:17 +01:00
Alexandre Janniaux
0e58316050 FichinterTest: create Societe object
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
       ┴
2024-01-04 17:04:45 +01:00
Alexandre Janniaux
a07ad0fe73 FichinterTest: add errorsToString()
Adding $localobject->errorsToString() as third argument to the assert
will allow to forward internal errors towards the tests and display them
accordingly.
2024-01-04 17:02:12 +01:00
Laurent Destailleur
482adfd7a0 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-12-30 13:11:15 +01:00
Laurent Destailleur
a04b714d28 Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0 2023-12-30 13:10:42 +01:00
Laurent Destailleur
14cc6c0332 Fix phpunit 2023-12-30 13:09:41 +01:00
Laurent Destailleur
ef312e960c Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-12-29 16:53:09 +01:00
Laurent Destailleur
d2b3920684 Merge 2023-12-29 16:51:05 +01:00
MDW
b5b8a2a874 Fix utf8_encoding/decoding (PHP8.2 deprecation)
Fix files that were missed in #27018
2023-12-27 19:45:37 +01:00
Laurent Destailleur
61c5c6f88d Fix regression 2023-12-27 13:09:25 +01:00
Laurent Destailleur
6386b02963 Fix phpunit for postgresql 2023-12-19 15:10:59 +01:00
Laurent Destailleur
97ae114265 FIX Universal search syntax accept string with ' in the IN 2023-12-19 15:01:21 +01:00
Laurent Destailleur
d423665551 Fix regression 2023-12-19 14:12:13 +01:00
Laurent Destailleur
e7c405425c Debug v19 2023-12-19 14:03:17 +01:00
Laurent Destailleur
b3762798a7
Merge pull request #27149 from alexandre-janniaux/commande-test-create-soc/1
FIX: CommandeTest: fix create when no company exists
2023-12-17 20:54:23 +01:00
Laurent Destailleur
a9bdab922b
Merge pull request #27150 from alexandre-janniaux/companybankaccounttest-societe/1
FIX: CompanyBankAccountTest: fix create when no societe exists
2023-12-17 20:54:07 +01:00
Alexandre Janniaux
f728bda625 ContratTest: add more error context 2023-12-17 16:06:06 +01:00
Alexandre Janniaux
c2c99ab2b8 FIX: ContratTest: fix create when no societe exists
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.
2023-12-17 16:06:05 +01:00
Alexandre Janniaux
da3b4d10df FIX: CompanyBankAccountTest: fix create when no societe exists
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.
2023-12-17 15:55:26 +01:00
Alexandre Janniaux
0cc1cfc1ee FIX: CommandeTest: fix create when no company exists
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.
2023-12-17 15:45:25 +01:00
Florian HENRY
8be0970a0c review test 2023-12-13 11:47:25 +01:00
Florian HENRY
82c49e62d1 add unit test for image in email with src=../media/ or src=base64 2023-12-13 11:31:42 +01:00
Laurent Destailleur
29dc12dd58 Option MAIN_DISALLOW_URL_INTO_DESCRIPTIONS accept 1 or 2 value.
Value 1 should be ready to be on by default in a next version.
Fix #yogosha18900
2023-12-10 16:19:05 +01:00
Laurent Destailleur
729451faa2 FIX To support domain names with TLD on 2 levels. 2023-12-06 00:46:00 +01:00
Laurent Destailleur
c9fc494796 FIX To support domain names with TLD on 2 levels. 2023-12-06 00:27:52 +01:00
Laurent Destailleur
de7d3c2bf8 Fix with php-cs-fixer 2023-12-04 11:22:28 +01:00
Laurent Destailleur
0d1983766e Fix order of param 2023-12-01 19:48:26 +01:00
Laurent Destailleur
da244466b7 Add phpunit on utf8_check and utf8_valid 2023-11-30 21:22:20 +01:00
Laurent Destailleur
c417949a7e Fix phpunit 2023-11-30 00:06:05 +01:00
Laurent Destailleur
3e1d5b1748 Fix for MAIN_RESTRICTHTML_ONLY_VALID_HTML 2023-11-29 23:17:22 +01:00
Laurent Destailleur
d809825c21 Fix phpunit 2023-11-29 22:02:10 +01:00
Laurent Destailleur
0d61ee74c7 Fix phpunit 2023-11-29 20:32:03 +01:00
Laurent Destailleur
43f9210ab4 SEC: Add option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY 2023-11-29 20:19:21 +01:00
Laurent Destailleur
955ecd1c16 Fix params in phpunit 2023-11-28 15:35:31 +01:00
Laurent Destailleur
1d589fd74e Fix warnings 2023-11-27 13:26:44 +01:00
Laurent Destailleur
4ecab54c28 Fix phpunit 2023-11-14 12:02:09 +01:00
Laurent Destailleur
659cdfa975 Add a test with a german char 2023-11-06 20:35:41 +01:00
Laurent Destailleur
604b01e803 Show error message 2023-11-06 00:56:44 +01:00
Alexandre Janniaux
c3b3840f08
QUAL Refactor merging companies and fix #26272 with Reception objects (#26320)
* 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>
2023-10-26 16:30:38 +02:00
Laurent Destailleur
96a90cf552 Add test file 2023-10-24 03:25:50 +02:00
Alexandre Janniaux
9fe9eee18a
FIX|Fix some minor issues on Reception and add a new test for it (#26310)
* 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.
2023-10-21 16:28:30 +02:00
Laurent Destailleur
7a694d3485 Fix phpunit 2023-10-20 03:59:02 +02:00
Laurent Destailleur
9a8db612b3 Fix phpunit error 2023-10-17 15:48:38 +02:00
Laurent Destailleur
c1b74f9338 Fix phpunit regression 2023-09-29 17:04:11 +02:00
Laurent Destailleur
72e17fe60e Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
2023-09-29 16:53:54 +02:00
Laurent Destailleur
b21a24aa97 Add AssetModel in AllTest 2023-09-26 20:52:49 +02:00
Hystepik
d157e8f660 New asset model phpunit test 2023-09-25 14:54:32 +02:00
Laurent Destailleur
557fe235d1 Fix warnings 2023-09-10 19:41:14 +02:00
Laurent Destailleur
b2ae9ea888 Fix warnings 2023-09-10 15:23:32 +02:00
Laurent Destailleur
ad9e11542c Fix phpunit warning 2023-09-10 15:16:46 +02:00
Laurent Destailleur
bc71380410 Fix sql errors 2023-09-09 21:16:58 +02:00
Laurent Destailleur
fb5f4c1dc2 NEW Add phpunit for REST API of contacts 2023-09-08 21:12:59 +02:00
Laurent Destailleur
33288ee66a Try to fix phpunit on dol_eval 2023-09-08 19:10:44 +02:00
Laurent Destailleur
6dbd7e35f2 Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop 2023-09-08 14:17:17 +02:00
Laurent Destailleur
c379420d86 Fix regression in dol_eval 2023-09-08 14:12:12 +02:00
Laurent Destailleur
d91ce60ab4
Merge pull request #25819 from frederic34/setascustomer
deprecate set_as_client
2023-09-08 11:23:06 +02:00
Laurent Destailleur
e9787451a8 Disallow more use of parenthesis into dol_eval 2023-09-08 05:51:06 +02:00
Frédéric FRANCE
26dff90658 deprecate set_as_client 2023-09-06 14:38:35 +02:00
Laurent Destailleur
150de687bf Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-09-05 20:13:38 +02:00
Laurent Destailleur
0ed6a63fb0 FIX #CVE-2023-4197 2023-09-05 00:49:01 +02:00
Laurent Destailleur
552a079379 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-08-27 16:05:46 +02:00
Laurent Destailleur
45d323a6f8 Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0 2023-08-27 16:02:57 +02:00
Laurent Destailleur
4302a6bc04 Fix empty on getDolGlobal 2023-08-27 15:55:44 +02:00
Laurent Destailleur
c0e2d55549 Fix warnings 2023-08-26 00:43:51 +02:00
Laurent Destailleur
1293f48018 Fix phpunit 2023-08-26 00:05:58 +02:00
Laurent Destailleur
a0455c72a3 Test phpunit 2023-08-25 23:44:55 +02:00
Laurent Destailleur
a296751543 Fix phpunit 2023-08-25 22:04:37 +02:00
Laurent Destailleur
4c2645147c Fix phpunit API warnings 2023-08-25 15:52:31 +02:00
Laurent Destailleur
7e062f9391 Fix phpunit API warnings 2023-08-25 15:49:09 +02:00
Laurent Destailleur
c6a30bcf9e Fix phpunit 2023-08-25 15:45:12 +02:00
Laurent Destailleur
256fe9ecf8 Add more REST phpunit tests 2023-08-25 14:48:41 +02:00
Laurent Destailleur
bcd3401e47 Fix phpunit 2023-08-25 13:58:27 +02:00
oussamanhairech
572192a01f #14295 Rest API Contact test 2023-08-24 18:21:06 +02:00
Laurent Destailleur
e1dbeb58ea Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-08-13 16:35:08 +02:00
Laurent Destailleur
310ef11dac FIX WAF 2023-08-13 15:45:45 +02:00
Laurent Destailleur
b3f8795414 Fix phpunit 2023-08-12 01:08:04 +02:00
Laurent Destailleur
c9f1ee08dc Fix phpunit 2023-08-11 20:15:01 +02:00
Laurent Destailleur
df4761e42a Fix numbering of shipments 2023-08-11 12:14:28 +02:00
Laurent Destailleur
1aa535e994 Fix regressions 2023-08-06 01:41:53 +02:00
Laurent Destailleur
216ab4c190 Fix phpunit 2023-08-04 17:26:38 +02:00
Laurent Destailleur
86864b4d53 Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0 2023-07-06 22:22:26 +02:00