2
0
forked from Wavyzz/dolibarr

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.
This commit is contained in:
MDW
2024-02-23 17:43:18 +01:00
committed by GitHub
parent 00e57fe765
commit f3a3de8ea2
3 changed files with 212 additions and 163 deletions

View File

@@ -618,135 +618,9 @@ class CodingPhpTest extends CommonClassTest
//trigger_error("Deprecated module name, use '$new_name': $message", E_USER_DEPRECATED);
} else {
$this->assertTrue(
isset(self::VALID_MODULE_MAPPING[$module_name]),
array_key_exists($module_name, self::VALID_MODULE_MAPPING),
"Unknown module: $message"
);
}
}
const DEPRECATED_MODULE_MAPPING = array(
'actioncomm' => 'agenda',
'adherent' => 'member',
'adherent_type' => 'member_type',
'banque' => 'bank',
'categorie' => 'category',
'commande' => 'order',
'contrat' => 'contract',
'entrepot' => 'stock',
'expedition' => 'delivery_note',
'facture' => 'invoice',
'fichinter' => 'intervention',
'product_fournisseur_price' => 'productsupplierprice',
'product_price' => 'productprice',
'projet' => 'project',
'propale' => 'propal',
'socpeople' => 'contact',
);
const VALID_MODULE_MAPPING = array(
'agenda' => 1,
'member' => 1,
'member_type' => 1,
'bank' => 1,
'category' => 1,
'delivery_note' => 1,
'order' => 1,
'contract' => 1,
'stock' => 1,
'invoice' => 1,
'intervention' => 1,
'productsupplierprice' => 1,
'productprice' => 1,
'project' => 1,
'propal' => 1,
'contact' => 1,
'accounting' => 1,
'ai' => 1,
'anothermodule' => 1,
'api' => 1,
'asset' => 1,
'barcode' => 1,
'blockedlog' => 1,
'bom' => 1,
'bookcal' => 1,
'bookmark' => 1,
'cashdesk' => 1,
'clicktodial' => 1,
'comptabilite' => 1,
'cron' => 1,
'datapolicy' => 1,
'debugbar' => 1,
'deplacement' => 1,
'don' => 1,
'dynamicprices' => 1,
'ecm' => 1,
'ecotax' => 1,
'emailcollector' => 1,
'eventorganization' => 1,
'expensereport' => 1,
'export' => 1,
'externalsite' => 1,
'fckeditor' => 1,
'ficheinter' => 1,
'fournisseur' => 1,
'ftp' => 1,
'google' => 1,
'gravatar' => 1,
'holiday' => 1,
'hrm' => 1,
'import' => 1,
'incoterm' => 1,
'intracommreport' => 1,
'knowledgemanagement' => 1,
'label' => 1,
'ldap' => 1,
'loan' => 1,
'mailing' => 1,
'mailman' => 1,
'mailmanspip' => 1,
'margin' => 1,
'memcached' => 1,
'modulebuilder' => 1,
'mrp' => 1,
'multicompany' => 1,
'multicurrency' => 1,
'mymodule' => 1,
'notification' => 1,
'numberwords' => 1,
'openstreetmap' => 1,
'opensurvey' => 1,
'partnership' => 1,
'paybox' => 1,
'paymentbybanktransfer' => 1,
'paypal' => 1,
'paypalplus' => 1,
'prelevement' => 1,
'product' => 1,
'productbatch' => 1,
'receiptprinter' => 1,
'reception' => 1,
'recruitment' => 1,
'resource' => 1,
'salaries' => 1,
'service' => 1,
'socialnetworks' => 1,
'societe' => 1,
'stocktransfer' => 1,
'stripe' => 1,
'supplier_invoice' => 1,
'supplier_order' => 1,
'supplier_proposal' => 1,
'syslog' => 1,
'takepos' => 1,
'tax' => 1,
'ticket' => 1,
'user' => 1,
'variants' => 1,
'webhook' => 1,
'webportal' => 1,
'webservices' => 1,
'website' => 1,
'workflow' => 1,
'workstation' => 1,
'zapier' => 1,
);
}