From a127a2299b1686de73a28af36be8bf52e961daa3 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Mar 2021 13:03:43 -0300 Subject: [PATCH] Bug 27898: Unit tests This patch adds unit tests for the PUT /holds/:hold_id route so it accepts the x-koha-override header and is able to override pickup location constraints. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/api/v1/holds.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index f01d5de427b..56ae481cb8d 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -860,7 +860,7 @@ subtest 'pickup_locations() tests' => sub { subtest 'edit() tests' => sub { - plan tests => 14; + plan tests => 20; $schema->storage->txn_begin; @@ -885,6 +885,7 @@ subtest 'edit() tests' => sub { # Disable logging t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); + t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); my $mock_biblio = Test::MockModule->new('Koha::Biblio'); my $mock_item = Test::MockModule->new('Koha::Item'); @@ -930,6 +931,12 @@ subtest 'edit() tests' => sub { $biblio_hold->discard_changes; is( $biblio_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); + $t->put_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id + => { 'x-koha-override' => 'any' } + => json => $biblio_hold_data ) + ->status_is(200) + ->json_has( '/pickup_library_id' => $library_1->id ); + $biblio_hold_data->{pickup_library_id} = $library_2->branchcode; $t->put_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id @@ -964,6 +971,12 @@ subtest 'edit() tests' => sub { $item_hold->discard_changes; is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); + $t->put_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id + => { 'x-koha-override' => 'any' } + => json => $item_hold_data ) + ->status_is(200) + ->json_has( '/pickup_library_id' => $library_1->id ); + $item_hold_data->{pickup_library_id} = $library_2->branchcode; $t->put_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id -- 2.30.1