From 00970925ae848aa13b2a239b1fa3655d8ffb8441 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 21 Oct 2019 18:37:07 +0100 Subject: [PATCH] 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 Signed-off-by: Martin Renvoize --- t/db_dependent/Accounts.t | 38 ++++++++++++++++++++++++----------- t/db_dependent/ILSDI_Services.t | 1 + t/db_dependent/Koha/Account/Offsets.t | 7 ++++++- t/db_dependent/Members.t | 15 ++++++++------ 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 4e93b9e85b..a7311b5a81 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -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, } } ); diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index b1288ec469..8cc93374b5 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -201,6 +201,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes value => { borrowernumber => $brwr->{borrowernumber}, accounttype => 'xxx', + debit_type_code => undef, amountoutstanding => 10 } } diff --git a/t/db_dependent/Koha/Account/Offsets.t b/t/db_dependent/Koha/Account/Offsets.t index 8befae50cf..7e5e33f44b 100755 --- a/t/db_dependent/Koha/Account/Offsets.t +++ b/t/db_dependent/Koha/Account/Offsets.t @@ -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; diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index cdfa209c1f..dbda295dda 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -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; -- 2.11.4.GIT