From 92257bb4788123d4b13d5aec79581250b389b2e0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 17 Oct 2023 09:03:33 -0300 Subject: [PATCH] Bug 35053: Regression tests --- t/db_dependent/api/v1/holds.t | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index 245e5e6a091..37294869b5c 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -1097,7 +1097,7 @@ subtest 'edit() tests' => sub { subtest 'add() tests' => sub { - plan tests => 21; + plan tests => 24; $schema->storage->txn_begin; @@ -1139,17 +1139,22 @@ subtest 'add() tests' => sub { return Koha::Libraries->search( { branchcode => [ $library_2->branchcode, $library_3->branchcode ] } ); }); - my $can_be_reserved = 'OK'; + my $can_biblio_be_reserved = 'OK'; + my $can_item_be_reserved = 'OK'; + my $mock_reserves = Test::MockModule->new('C4::Reserves'); - $mock_reserves->mock( 'CanItemBeReserved', sub - { - return { status => $can_be_reserved } + + $mock_reserves->mock( + 'CanItemBeReserved', + sub { + return { status => $can_item_be_reserved }; } ); - $mock_reserves->mock( 'CanBookBeReserved', sub - { - return { status => $can_be_reserved } + $mock_reserves->mock( + 'CanBookBeReserved', + sub { + return { status => $can_biblio_be_reserved }; } ); @@ -1243,7 +1248,18 @@ subtest 'add() tests' => sub { ->status_is(400) ->json_is({ error => 'The supplied pickup location is not valid' }); + $can_item_be_reserved = 'notReservable'; + $can_biblio_be_reserved = 'OK'; + $item_hold_data->{pickup_library_id} = $library_2->branchcode; + + $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data ) + ->status_is(403, 'Item checks performed when both biblio_id and item_id passed (Bug 35053)') + ->json_is({ error => 'Hold cannot be placed. Reason: notReservable' }); + + $can_item_be_reserved = 'OK'; + $can_biblio_be_reserved = 'OK'; + $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data ) ->status_is(201); -- 2.42.0