mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
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.
This commit is contained in:
parent
d4f61dcf59
commit
da3b4d10df
|
|
@ -140,12 +140,18 @@ class CompanyBankAccountTest extends PHPUnit\Framework\TestCase
|
|||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "CompanyBankAccountTest Unittest";
|
||||
$socid = $soc->create($user);
|
||||
$this->assertLessThan($socid, 0, $soc->errorsToString());
|
||||
|
||||
$localobject=new CompanyBankAccount($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->socid = $socid;
|
||||
$result=$localobject->create($user);
|
||||
|
||||
print __METHOD__." result=".$result." id=".$localobject->id."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
$this->assertLessThan($result, 0, $localobject->errorsToString());
|
||||
return $localobject->id;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user