Bug 23049: (QA follow-up) Check constraint test corrections

TestBuilder adds random data which breaks the check constraint rule. The
simplest way to correct this situation is to override testbuilder by
passing in explicit undefs for accounttype or debit_type_code in the
tests.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-10-21 18:37:07 +01:00
parent aec46d0c3c
commit 00970925ae
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 42 additions and 19 deletions

View File

@ -394,11 +394,17 @@ subtest "More Koha::Account::pay tests" => sub {
})->{ borrowernumber };
my $amount = 100;
my $accountline = $builder->build({ source => 'Accountline',
value => { borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount }
});
my $accountline = $builder->build(
{
source => 'Accountline',
value => {
borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount,
accounttype => undef,
}
}
);
my $rs = $schema->resultset('Accountline')->search({
borrowernumber => $borrowernumber
@ -448,11 +454,17 @@ subtest "Even more Koha::Account::pay tests" => sub {
my $amount = 100;
my $partialamount = 60;
my $accountline = $builder->build({ source => 'Accountline',
value => { borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount }
});
my $accountline = $builder->build(
{
source => 'Accountline',
value => {
borrowernumber => $borrowernumber,
amount => $amount,
amountoutstanding => $amount,
accounttype => undef,
}
}
);
my $rs = $schema->resultset('Accountline')->search({
borrowernumber => $borrowernumber
@ -500,7 +512,8 @@ subtest 'balance' => sub {
value => {
borrowernumber => $patron->borrowernumber,
amount => 42,
amountoutstanding => 42
amountoutstanding => 42,
accounttype => undef,
}
}
);
@ -510,7 +523,8 @@ subtest 'balance' => sub {
value => {
borrowernumber => $patron->borrowernumber,
amount => -13,
amountoutstanding => -13
amountoutstanding => -13,
debit_type_code => undef,
}
}
);

View File

@ -201,6 +201,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
value => {
borrowernumber => $brwr->{borrowernumber},
accounttype => 'xxx',
debit_type_code => undef,
amountoutstanding => 10
}
}

View File

@ -35,7 +35,12 @@ subtest 'total_outstanding() tests' => sub {
$schema->storage->txn_begin;
my $line = $builder->build_object( { class => 'Koha::Account::Lines' } );
my $line = $builder->build_object(
{
class => 'Koha::Account::Lines',
value => { debit_type_code => undef }
}
);
my $amount_1 = 100;
my $amount_2 = 200;

View File

@ -367,13 +367,16 @@ subtest 'purgeSelfRegistration' => sub {
});
is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with checkout");
my $account_line = $builder->build_object({
class=>'Koha::Account::Lines',
value=>{
borrowernumber=>$self_reg->borrowernumber,
amountoutstanding=>5
my $account_line = $builder->build_object(
{
class => 'Koha::Account::Lines',
value => {
borrowernumber => $self_reg->borrowernumber,
amountoutstanding => 5,
acocunttype => undef
}
}
});
);
is( C4::Members::DeleteExpiredOpacRegistrations(), 0, "DeleteExpiredOpacRegistrations doesn't delete borrower with checkout and fine");
$checkout->delete;