Bug 28254: Add missing tests for PUT and POST

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-05-04 15:04:17 +02:00
parent 5627f69b2c
commit f22a7e3239
1 changed files with 26 additions and 2 deletions

View File

@ -358,7 +358,7 @@ $schema->storage->txn_rollback;
subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub {
plan tests => 16;
plan tests => 18;
$schema->storage->txn_begin;
@ -445,6 +445,12 @@ subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub {
{ 'x-koha-override' => 'any' } => json => $post_data )
->status_is(201);
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0);
$t->post_ok( "//$userid:$password@/api/v1/holds" =>
{ 'x-koha-override' => 'any' } => json => $post_data )
->status_is(400);
$schema->storage->txn_rollback;
};
@ -1136,7 +1142,7 @@ subtest 'add() tests' => sub {
subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub {
plan tests => 20;
plan tests => 28;
$schema->storage->txn_begin;
@ -1251,5 +1257,23 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub {
is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' );
$t->put_ok( "//$userid:$password@/api/v1/holds/"
. $hold->id
. "/pickup_location" => json => { pickup_library_id => $library_3->branchcode } )
->status_is(400)
->json_is({ error => '[The supplied pickup location is not valid]' });
is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'invalid pickup library not used' );
$t->put_ok( "//$userid:$password@/api/v1/holds/"
. $hold->id
. "/pickup_location"
=> { 'x-koha-override' => 'any' }
=> json => { pickup_library_id => $library_3->branchcode } )
->status_is(400)
->json_is({ error => '[The supplied pickup location is not valid]' });
is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'invalid pickup library not used, even if x-koha-override is passed' );
$schema->storage->txn_rollback;
};