View | Details | Raw Unified | Return to bug 28254
Collapse All | Expand All

(-)a/t/db_dependent/api/v1/holds.t (-27 / +8 lines)
Lines 1142-1150 subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { Link Here
1142
1142
1143
    my $password = 'AbcdEFG123';
1143
    my $password = 'AbcdEFG123';
1144
1144
1145
    my $library_1 = $builder->build_object({ class => 'Koha::Libraries' });
1145
    # library_1 and library_2 are available pickup locations, not library_3
1146
    my $library_2 = $builder->build_object({ class => 'Koha::Libraries' });
1146
    my $library_1 = $builder->build_object(
1147
    my $library_3 = $builder->build_object({ class => 'Koha::Libraries' });
1147
        { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
1148
    my $library_2 = $builder->build_object(
1149
        { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
1150
    my $library_3 = $builder->build_object(
1151
        { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
1148
1152
1149
    my $patron = $builder->build_object(
1153
    my $patron = $builder->build_object(
1150
        { class => 'Koha::Patrons', value => { flags => 0 } } );
1154
        { class => 'Koha::Patrons', value => { flags => 0 } } );
Lines 1165-1182 subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { Link Here
1165
    t::lib::Mocks::mock_preference( 'HoldsLog',      0 );
1169
    t::lib::Mocks::mock_preference( 'HoldsLog',      0 );
1166
    t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
1170
    t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
1167
1171
1168
    my $libraries_query = { branchcode => [ $library_1->branchcode, $library_2->branchcode ] };
1169
1170
    my $mocked_biblio = Test::MockModule->new('Koha::Biblio');
1171
    $mocked_biblio->mock( 'pickup_locations', sub {
1172
        return Koha::Libraries->search($libraries_query);
1173
    });
1174
1175
    my $mocked_item = Test::MockModule->new('Koha::Item');
1176
    $mocked_item->mock( 'pickup_locations', sub {
1177
        return Koha::Libraries->search($libraries_query);
1178
    });
1179
1180
    my $biblio = $builder->build_sample_biblio;
1172
    my $biblio = $builder->build_sample_biblio;
1181
    my $item   = $builder->build_sample_item(
1173
    my $item   = $builder->build_sample_item(
1182
        {
1174
        {
Lines 1206-1213 subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { Link Here
1206
1198
1207
    is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' );
1199
    is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' );
1208
1200
1209
    $libraries_query = { branchcode => $library_1->branchcode };
1210
1211
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1201
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1212
          . $hold->id
1202
          . $hold->id
1213
          . "/pickup_location" => json => { pickup_library_id => $library_3->branchcode } )
1203
          . "/pickup_location" => json => { pickup_library_id => $library_3->branchcode } )
Lines 1229-1240 subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { Link Here
1229
        )
1219
        )
1230
    );
1220
    );
1231
1221
1232
    $libraries_query = { branchcode => $library_1->branchcode };
1233
1234
    # Attempt to use an invalid pickup locations ends in 400
1222
    # Attempt to use an invalid pickup locations ends in 400
1235
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1223
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1236
          . $hold->id
1224
          . $hold->id
1237
          . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )
1225
          . "/pickup_location" => json => { pickup_library_id => $library_3->branchcode } )
1238
      ->status_is(400)
1226
      ->status_is(400)
1239
      ->json_is({ error => '[The supplied pickup location is not valid]' });
1227
      ->json_is({ error => '[The supplied pickup location is not valid]' });
1240
1228
Lines 1255-1266 subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { Link Here
1255
1243
1256
    t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 );
1244
    t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 );
1257
1245
1258
    $libraries_query = {
1259
        branchcode => {
1260
            '-in' => [ $library_1->branchcode, $library_2->branchcode ]
1261
        }
1262
    };
1263
1264
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1246
    $t->put_ok( "//$userid:$password@/api/v1/holds/"
1265
          . $hold->id
1247
          . $hold->id
1266
          . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )
1248
          . "/pickup_location" => json => { pickup_library_id => $library_2->branchcode } )
1267
- 

Return to bug 28254