|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 12; |
20 |
use Test::More tests => 13; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
| 23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
|
Lines 1011-1013
subtest 'add() tests' => sub {
Link Here
|
| 1011 |
|
1011 |
|
| 1012 |
$schema->storage->txn_rollback; |
1012 |
$schema->storage->txn_rollback; |
| 1013 |
}; |
1013 |
}; |
| 1014 |
- |
1014 |
|
|
|
1015 |
|
| 1016 |
subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { |
| 1017 |
|
| 1018 |
plan tests => 4; |
| 1019 |
|
| 1020 |
$schema->storage->txn_begin; |
| 1021 |
|
| 1022 |
my $password = 'AbcdEFG123'; |
| 1023 |
|
| 1024 |
my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); |
| 1025 |
my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); |
| 1026 |
|
| 1027 |
my $patron = $builder->build_object( |
| 1028 |
{ class => 'Koha::Patrons', value => { flags => 0 } } ); |
| 1029 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 1030 |
my $userid = $patron->userid; |
| 1031 |
$builder->build( |
| 1032 |
{ |
| 1033 |
source => 'UserPermission', |
| 1034 |
value => { |
| 1035 |
borrowernumber => $patron->borrowernumber, |
| 1036 |
module_bit => 6, |
| 1037 |
code => 'place_holds', |
| 1038 |
}, |
| 1039 |
} |
| 1040 |
); |
| 1041 |
|
| 1042 |
# Disable logging |
| 1043 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
| 1044 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
| 1045 |
|
| 1046 |
my $biblio = $builder->build_sample_biblio; |
| 1047 |
my $hold = Koha::Holds->find( |
| 1048 |
AddReserve( |
| 1049 |
{ |
| 1050 |
branchcode => $library_1->branchcode, |
| 1051 |
borrowernumber => $patron->borrowernumber, |
| 1052 |
biblionumber => $biblio->biblionumber, |
| 1053 |
priority => 1, |
| 1054 |
} |
| 1055 |
) |
| 1056 |
); |
| 1057 |
|
| 1058 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
| 1059 |
. $hold->id |
| 1060 |
. "/pickup_location" => json => $library_2->branchcode )->status_is(200)->json_is($library_2->branchcode); |
| 1061 |
|
| 1062 |
is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); |
| 1063 |
|
| 1064 |
$schema->storage->txn_rollback; |
| 1065 |
}; |