From cdbc4f644ba209c5f4ee7f161bf111eb2d5f6c08 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 23 Feb 2023 15:32:21 +0000 Subject: [PATCH] Bug 33055: (bug 32624 follow-up) Unit tests Signed-off-by: Martin Renvoize --- t/db_dependent/SIP/Patron.t | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t index de3526df58..04baa9e7bc 100755 --- a/t/db_dependent/SIP/Patron.t +++ b/t/db_dependent/SIP/Patron.t @@ -276,7 +276,7 @@ $schema->storage->txn_rollback; subtest "NoIssuesChargeGuarantees tests" => sub { - plan tests => 5; + plan tests => 6; t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' ); @@ -320,13 +320,14 @@ subtest "NoIssuesChargeGuarantees tests" => sub { is( $sip_patron->fines_amount, 0.11,"Guarantee only fines correctly counted"); ok( $sip_patron->charge_ok, "Guarantee not blocked by guarantor fines"); + unlike( $sip_patron->screen_msg, qr/Patron blocked by fines .* on guaranteed accounts/,"Screen message does not include blocked message"); $schema->storage->txn_rollback; }; subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub { - plan tests => 6; + plan tests => 12; t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' ); @@ -361,15 +362,29 @@ subtest "NoIssuesChargeGuarantorsWithGuarantees tests" => sub { my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - is( $sip_patron->fines_amount, 11, "Guarantee fines correctly included"); + is( $sip_patron->fines_amount, 11, "Personal fines correctly reported"); ok( !$sip_patron->charge_ok, "Guarantor blocked"); like( $sip_patron->screen_msg, qr/Patron blocked by fines \(11\.11\) on related accounts/,"Screen message includes related fines total"); $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber ); - is( $sip_patron->fines_amount, 0.11, "Guarantor fines correctly included"); + is( $sip_patron->fines_amount, 0.11, "Personal fines correctly reported"); ok( !$sip_patron->charge_ok, "Guarantee blocked"); like( $sip_patron->screen_msg, qr/Patron blocked by fines \(11\.11\) on related accounts/,"Screen message includes related fines total"); + t::lib::Mocks::mock_preference('NoIssuesChargeGuarantorsWithGuarantees', 12.01); + + $sip_patron = C4::SIP::ILS::Patron->new( $child->cardnumber ); + + is( $sip_patron->fines_amount, 0.11, "Personal fines correctly reported"); + ok( $sip_patron->charge_ok, "Guarantee not blocked"); + unlike( $sip_patron->screen_msg, qr/Patron blocked by fines .* on related accounts/,"Screen message does not indicate block"); + + $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + + is( $sip_patron->fines_amount, 11, "Personal fines correctly reported"); + ok( $sip_patron->charge_ok, "Patron not blocked"); + unlike( $sip_patron->screen_msg, qr/Patron blocked by fines .* on related accounts/,"Screen message does not indicate block"); + $schema->storage->txn_rollback; }; -- 2.39.2