More robust phpunit
This commit is contained in:
parent
234607a3dd
commit
5cf7b54c41
4 changed files with 44 additions and 7 deletions
|
|
@ -42,6 +42,7 @@ define('DOL_MAJOR_VERSION', '24');
|
|||
define('DOL_VERSION', constant('DOL_MAJOR_VERSION').'.'.constant('DOL_MINOR_VERSION'));
|
||||
// DOL_VERSION is now a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
|
||||
|
||||
// Set to 1 if the beta version is a just a candidate for certification or if the stable version has been certified.
|
||||
// Use 2 to force LNE features for debug purposes
|
||||
define('CERTIF_LNE', '0');
|
||||
// Set to 1 if the beta version is the candidate for certification or if the stable version has been certified.
|
||||
// Use 2 to force LNE features for debug purposes.
|
||||
// Unset for standard version.
|
||||
//define('CERTIF_LNE', '2');
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ global $conf,$user,$langs,$db;
|
|||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/blockedlog/class/blockedlog.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/modBlockedLog.class.php';
|
||||
require_once dirname(__FILE__).'/CommonClassTest.class.php';
|
||||
|
||||
if (empty($user->id)) {
|
||||
|
|
@ -51,6 +52,23 @@ $langs->load("main");
|
|||
*/
|
||||
class BlockedLogAndLNETest extends CommonClassTest
|
||||
{
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::assertTrue(isModEnabled('invoice'), " module customer invoice must be enabled");
|
||||
self::assertFalse(isModEnabled('ecotaxdeee'), " module ecotaxdeee must not be enabled");
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// We disable module blocked log to avoid interference with tests
|
||||
global $db;
|
||||
$blockedlogmodule = new modBlockedLog($db);
|
||||
$blockedlogmodule->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* testBlockedLogAndLNETest
|
||||
*
|
||||
|
|
|
|||
|
|
@ -320,7 +320,9 @@ abstract class CommonClassTest extends TestCase
|
|||
} else {
|
||||
$oVarsA = get_object_vars($oA);
|
||||
$oVarsB = get_object_vars($oB);
|
||||
|
||||
$aKeys = array_keys($oVarsA);
|
||||
|
||||
if (method_exists($oA, 'deprecatedProperties')) {
|
||||
// Update exclusions
|
||||
foreach (self::callMethod($oA, 'deprecatedProperties') as $deprecated => $new) {
|
||||
|
|
@ -333,6 +335,7 @@ abstract class CommonClassTest extends TestCase
|
|||
if (in_array($sKey, $fieldstoignorearray)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) {
|
||||
$retAr[] = get_class($oA).'::'.$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : json_encode($oVarsA[$sKey])).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : json_encode($oVarsB[$sKey]));
|
||||
}
|
||||
|
|
@ -341,6 +344,7 @@ abstract class CommonClassTest extends TestCase
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $retAr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ global $conf,$user,$langs,$db;
|
|||
//require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/modBlockedLog.class.php';
|
||||
require_once dirname(__FILE__).'/CommonClassTest.class.php';
|
||||
|
||||
if (empty($user->id)) {
|
||||
|
|
@ -60,6 +61,11 @@ class FactureTest extends CommonClassTest
|
|||
self::assertTrue(isModEnabled('invoice'), " module customer invoice must be enabled");
|
||||
self::assertFalse(isModEnabled('ecotaxdeee'), " module ecotaxdeee must not be enabled");
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// We disable module blocked log to avoid interference with tests
|
||||
global $db;
|
||||
$blockedlogmodule = new modBlockedLog($db);
|
||||
$blockedlogmodule->remove();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -151,6 +157,10 @@ class FactureTest extends CommonClassTest
|
|||
$langs = $this->savlangs;
|
||||
$db = $this->savdb;
|
||||
|
||||
// Force to default setup
|
||||
$conf->global->FAC_FORCE_DATE_VALIDATION = 0;
|
||||
$conf->global->INVOICE_CHECK_POSTERIOR_DATE = 0;
|
||||
|
||||
$result = $localobject->validate($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
|
||||
|
|
@ -161,9 +171,10 @@ class FactureTest extends CommonClassTest
|
|||
$newlocalobject->initAsSpecimen();
|
||||
$this->changeProperties($newlocalobject);
|
||||
|
||||
// Hack to avoid test to be wrong when module sellyoursaas is on
|
||||
unset($localobject->array_options['options_commission']);
|
||||
unset($localobject->array_options['options_reseller']);
|
||||
// Hack to avoid test to be wrong when some modules are one
|
||||
unset($localobject->array_options);
|
||||
//unset($localobject->array_options['options_reseller']);
|
||||
//unset($localobject->array_options['options_reseller']);
|
||||
|
||||
$arraywithdiff = $this->objCompare(
|
||||
$localobject,
|
||||
|
|
@ -179,7 +190,8 @@ class FactureTest extends CommonClassTest
|
|||
'trackid','user_creat','user_valid', 'note'
|
||||
)
|
||||
);
|
||||
$this->assertEquals($arraywithdiff, array()); // Actual, Expected
|
||||
|
||||
$this->assertEquals($arraywithdiff, array(), 'Found differences '.var_export($arraywithdiff, true)); // Actual, Expected. If it differs, do a var_dump($arraywithdiff) to see what differs
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
|
|
@ -261,6 +273,8 @@ class FactureTest extends CommonClassTest
|
|||
print __METHOD__." id=".$localobject->id." ref=".$localobject->ref." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice');
|
||||
|
||||
var_dump($localobject2->is_erasable());
|
||||
|
||||
$result = $localobject2->delete($user); // Deletion is OK, it is last invoice
|
||||
print __METHOD__." id=".$localobject2->id." ref=".$localobject2->ref." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice');
|
||||
|
|
|
|||
Loading…
Reference in a new issue