From a46cbac6e9e5b8033671951544176d62c889d089 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 26 Feb 2021 09:44:30 -0500 Subject: [PATCH] Bug 27808: Add unit tests Signed-off-by: Lisette Scheer --- t/db_dependent/Circulation.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 97ca6492e2..85f29b6563 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 52; +use Test::More tests => 53; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -4738,6 +4738,35 @@ subtest 'AddIssue records staff who checked out item if appropriate' => sub { is( $issue->issuer, $issuer->{borrowernumber}, "Staff who checked out the item recorded when RecordStaffUserOnCheckout turned on" ); }; +subtest "Item's onloan value should be set if checked out item is checked out to a different patron" => sub { + plan tests => 2; + + my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron_1 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $library_1->branchcode } + } + ); + my $patron_2 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $library_1->branchcode } + } + ); + + my $item = $builder->build_sample_item( + { + library => $library_1->branchcode, + } + ); + + AddIssue( $patron_1->unblessed, $item->barcode ); + ok( $item->get_from_storage->onloan, "Item's onloan column is set after initial checkout" ); + AddIssue( $patron_2->unblessed, $item->barcode ); + ok( $item->get_from_storage->onloan, "Item's onloan column is set after second checkout" ); +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); -- 2.11.0