From f4aae4e35bf78ed82a110fdefbb92ad10e1f2e54 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 23 Aug 2022 12:15:09 -0400 Subject: [PATCH] Bug 12225: Add unit tests Signed-off-by: Martin Renvoize --- t/db_dependent/SIP/Transaction.t | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index b17b33e635..e1e15ccb95 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -4,7 +4,7 @@ # Current state is very rudimentary. Please help to extend it! use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 16; use Koha::Database; use t::lib::TestBuilder; @@ -529,6 +529,43 @@ subtest do_checkout_with_patron_blocked => sub { }; +subtest do_checkout_with_noblock => sub { + plan tests => 3; + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + branchcode => $library->branchcode, + debarred => '9999/01/01', + }, + } + ); + + t::lib::Mocks::mock_userenv( + { branchcode => $library->branchcode, flags => 1 } ); + + my $item = $builder->build_sample_item( + { + library => $library->branchcode, + } + ); + + + my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); + is( $co_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" ); + is( $co_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" ); + + $co_transaction->do_checkout(undef, '19990102 030405'); + + is( $patron->checkouts->count, 1, 'No Block checkout was performed for debarred patron'); +}; + subtest do_checkout_with_holds => sub { plan tests => 7; -- 2.20.1