Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add test for Conf to checkout output directory consistencies. #29252

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

mdeweerd
Copy link
Contributor

@mdeweerd mdeweerd commented Apr 6, 2024

Add test for Conf to checkout output directory consistencies.

Test from #29221, failing in develop.

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd for me "dir_output" is deprecated, maybe use "multidir_output[$conf->entity]" instead?

@mdeweerd
Copy link
Contributor Author

@hregis Good comment. Does multidir_output must be checked for backward compatibility as well ? It seems that this would be a more complex test (I do not know the multidir_output principles).

Anyway, dir_output is still used, the purpose of this test is to ensure that when the path is the same for the old module name and the new one so that files are still found after an upgrade.

Currently, this fails for 3 old/new mappings in 3 different ways:

There were 3 failures:

1) ConfTest::testModulePaths with data set "banque" ('banque', 'bank')
Old (banque/expected) and new dir_output (bank/result) must be equal
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'D:/mdeweerd/workspace/precommit_dolibarr/documents/bank'
+'D:/mdeweerd/workspace/precommit_dolibarr/documents/banque'

2) ConfTest::testModulePaths with data set "expedition" ('expedition', 'shipping')    
Old (expedition/expected) and new dir_output (shipping/result) must be equal
Failed asserting that 'D:/mdeweerd/workspace/precommit_dolibarr/documents/expedition' matches expected null.

3) ConfTest::testModulePaths with data set "propale" ('propale', 'propal')
Old (propale/expected) and new dir_output (propal/result) must be equal
Failed asserting that null matches expected 'D:/mdeweerd/workspace/precommit_dolibarr/documents/propale'.

@eldy It would be nice to have this test integrated in the develop branch after fixing (or ignoring) the above mentionned errors.

@mdeweerd mdeweerd marked this pull request as ready for review August 20, 2024 12:51
@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd @eldy eventually "multidir_output" should replace "dir_output" (except for some specific paths), it allows to access the directories of the entities in "documents" when using the Multicompany module and the shares between entities. in general we define the entity of the object: "multidir_output[$object->entity]" or the current entity if the entity of the object does not exist: "multidir_output[$conf->entity]"

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd without Multicompany module, $object->entity and $conf->entity has the value 1

@mdeweerd
Copy link
Contributor Author

mdeweerd commented Aug 20, 2024

Ok, I'll add a test where the value is '1'. The change to multidir_output does not mean that the backward compatibility test itself is not useful.

There are still 1349 lines to update in the code:

$ git grep -n --column -F -- '->dir_output' :*php |wc
   1349    6666  168647

EDIT: New tests added. Good news: no extra failing tests!

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd yes normally the results will be the same :-) thanks

@mdeweerd
Copy link
Contributor Author

@hregis Found an issue between multidir_output and dir_output by adding a test to compare these values for all modules.

4) ConfTest::testModulePaths with data set "productbatch" ('productbatch', 'ProductBatch')
dir_output and multidir_output must be equal
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'D:/mdeweerd/workspace/precommit_dolibarr/documents/productlot'
+'D:/mdeweerd/workspace/precommit_dolibarr/documents/productbatch'

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd you can see this in conf.class.php ?

// Module productbatch
$this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd the creation of directory is empty in modProductBatch !

$this->dirs = array();

i don't know why "productlot" is used ?!

@eldy ? you know ?

@eldy
Copy link
Member

eldy commented Aug 20, 2024

@mdeweerd the creation of directory is empty in modProductBatch !

$this->dirs = array();

i don't know why "productlot" is used ?!

@eldy ? you know ?

Don't know, first code to add lot management added a module file modProductBatch and a dir name productlot, I see no reason why different name were used ;-(

@mdeweerd
Copy link
Contributor Author

OUt of grep for productlot:

Default assignement to dir_output (base on module name):

htdocs/core/class/conf.class.php:562:19:             $this->$module->dir_output = $rootfordata."/".$module;

Specific assignement for productbatch (changing from module name):

tdocs/core/class/conf.class.php:684:81:         $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
htdocs/core/class/conf.class.php:685:79:         $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");

@mdeweerd
Copy link
Contributor Author

mdeweerd commented Aug 20, 2024

The inconsistency for productlot goes back a long way - the test also fails for 16.0.1 .

So I checked git blame.

In Feb/2020 we had 'produitlot': (not productlot) for multidir_output - 13.0.

e44865d8b54a htdocs/core/class/conf.class.php (Scrutinizer Auto-Fixer 2020-02-21 16:53:37 +0000 440)       $this->productbatch->multidir_output = array($this->entity => $rootfordata."/produitlot");
e44865d8b54a htdocs/core/class/conf.class.php (Scrutinizer Auto-Fixer 2020-02-21 16:53:37 +0000 441)       $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/produitlot/temp");

One year later, that became 'productlot' for multidir_output:

16906abc097f htdocs/core/class/conf.class.php (Laurent Destailleur    2021-02-26 12:47:57 +0100 474)       $this->productbatch->multidir_output = array($this->entity => $rootfordata."/productlot");
16906abc097f htdocs/core/class/conf.class.php (Laurent Destailleur    2021-02-26 12:47:57 +0100 475)       $this->productbatch->multidir_temp = array($this->entity => $rootfortemp."/productlot/temp");

But dir_output was showing productbatch.

produitlot for multidir_output has been in place since 2018 (7.0):

f7e58f3c73ca htdocs/core/class/conf.class.php (All-3kcis                  2018-04-12 15:10:37 +0200 432)       $this->productbatch->multidir_output=array($this->entity => $rootfordata."/produitlot");
f7e58f3c73ca htdocs/core/class/conf.class.php (All-3kcis                  2018-04-12 15:10:37 +0200 433)       $this->productbatch->multidir_temp  =array($this->entity => $rootfordata."/produitlot/temp");

@hregis
Copy link
Contributor

hregis commented Aug 20, 2024

@mdeweerd @eldy
the English/French mix comes from the beginning...
Dolibarr is a French software at the base, so of course! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants