@@ -, +, @@ --- t/db_dependent/api/v1/holds.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/t/db_dependent/api/v1/holds.t +++ a/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 ] --