From 90ecde76cc6794a5a2f3d89da11e0f5f74c04685 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 8 Jan 2020 14:20:38 +0100 Subject: [PATCH] Bug 22806: Unit Tests Signed-off-by: David Nind --- t/db_dependent/ILSDI_Services.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index d7fe08f65f..8ef56b92f5 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -302,7 +302,7 @@ subtest 'LookupPatron test' => sub { subtest 'Holds test' => sub { - plan tests => 5; + plan tests => 7; $schema->storage->txn_begin; @@ -419,6 +419,7 @@ subtest 'Holds test' => sub { source => 'Item', value => { biblionumber => $biblio3->{biblionumber}, + barcode => '123456789', damaged => 0, itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, } @@ -451,6 +452,21 @@ subtest 'Holds test' => sub { $reply = C4::ILSDI::Services::HoldItem( $query ); is( $reply->{code}, 'damaged', "Item is damaged" ); + $patron = $builder->build_object({ class => 'Koha::Patrons' }); + my $module = new Test::MockModule('C4::Context'); + $module->mock('userenv', sub { { patron => $patron } }); + my $date_due = DateTime->now->add(weeks => 2); + my $issue = C4::Circulation::AddIssue($patron->unblessed, $item3->{barcode}, $date_due); + t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' ); + + $query->param( 'patron_id', $patron->borrowernumber); + $query->param( 'bib_id', $biblio3->{biblionumber}); + $query->param( 'item_id', $item3->{itemnumber}); + $reply = C4::ILSDI::Services::HoldItem( $query ); + + is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" ); + is( $reply->{pickup_location}, undef, "No reserve placed"); + $schema->storage->txn_rollback; }; -- 2.11.0