From 1058c877e497ae77798b05e601a466f8280abd70 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 Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 683b74d202d57f4c3fdad62d81b92bf49f7d1fc4) Signed-off-by: Fridolin Somers (cherry picked from commit 6de7575caee576335b2a764a117b70cc1171c472) Signed-off-by: Matt Blenkinsop --- 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 245e5e6a09..37294869b5 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.20.1