From 555a8f24ea1a147c84a9d4cdd979f9bf0d24ebe9 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 28 Apr 2021 14:55:52 -0300 Subject: [PATCH] Bug 28254: Unit tests Signed-off-by: Kyle M Hall --- t/db_dependent/api/v1/holds.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index 44a12447a0..beaaee5110 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -1136,7 +1136,7 @@ subtest 'add() tests' => sub { subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { - plan tests => 16; + plan tests => 20; $schema->storage->txn_begin; @@ -1240,6 +1240,21 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { is( $hold->discard_changes->branchcode->branchcode, $library_1->branchcode, 'pickup library unchanged' ); + t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); + + # Attempt to use an invalid pickup locations with override succeeds + $t->put_ok( "//$userid:$password@/api/v1/holds/" + . $hold->id + . "/pickup_location" + => { 'x-koha-override' => 'any' } + => json => { pickup_library_id => $library_2->branchcode } ) + ->status_is(200) + ->json_is({ pickup_library_id => $library_2->branchcode }); + + is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library changed' ); + + t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); + $libraries_query = { branchcode => { '-in' => [ $library_1->branchcode, $library_2->branchcode ] -- 2.24.3 (Apple Git-128)