From c6802e70edcc85b79cac11cc9dae1b3fa7ac1f28 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 8 Mar 2021 14:27:20 +0000 Subject: [PATCH] Bug 27895: Unit test --- t/db_dependent/Koha/Hold.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t index a6a5c4a7d6..ac3ef3ddd1 100755 --- a/t/db_dependent/Koha/Hold.t +++ b/t/db_dependent/Koha/Hold.t @@ -143,7 +143,7 @@ subtest 'set_pickup_location() tests' => sub { subtest 'is_pickup_location_valid() tests' => sub { - plan tests => 4; + plan tests => 5; $schema->storage->txn_begin; @@ -196,5 +196,11 @@ subtest 'is_pickup_location_valid() tests' => sub { ok( !$item_hold->is_pickup_location_valid({ library_id => $library_1->branchcode }), 'Pickup location invalid'); ok( $item_hold->is_pickup_location_valid({ library_id => $library_2->id }), 'Pickup location valid' ); + # let's mock what Koha::Item->pickup_locations returns, for testing + $mock_item->mock( 'pickup_locations', sub { + return Koha::Libraries->new()->empty; + }); + ok( !$item_hold->is_pickup_location_valid({ library_id => $library_2->id }), 'Pickup location invalid' ); + $schema->storage->txn_rollback; }; -- 2.11.0