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

(-)a/t/db_dependent/Koha/Item.t (-2 / +62 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 30;
23
use Test::More tests => 31;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 2301-2303 subtest 'current_branchtransfers relationship' => sub { Link Here
2301
2301
2302
    $schema->storage->txn_rollback;
2302
    $schema->storage->txn_rollback;
2303
};
2303
};
2304
- 
2304
2305
subtest 'update_item_location() tests' => sub {
2306
2307
    plan tests => 10;
2308
2309
    $schema->storage->txn_begin;
2310
2311
    my $location           = 'YA';
2312
    my $permanent_location = 'HEY';
2313
2314
    foreach my $action (qw{ checkin checkout }) {
2315
2316
        my $pref = $action eq 'checkin' ? 'UpdateItemLocationOnCheckin' : 'UpdateItemLocationOnCheckout';
2317
2318
        t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin',  q{} );
2319
        t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', q{} );
2320
2321
        my $item = $builder->build_sample_item( { location => $location, permanent_location => $permanent_location } );
2322
2323
        $item->update_item_location($action);
2324
2325
        is( $item->location, $location, "$pref does not modify value when not enabled" );
2326
2327
        t::lib::Mocks::mock_preference( $pref, qq{$location: GEN} );
2328
2329
        $item->update_item_location($action);
2330
2331
        is( $item->location, 'GEN', qq{'location' value set from '$location' to 'GEN' with setting `$location: GEN`} );
2332
2333
        t::lib::Mocks::mock_preference( $pref, q{_ALL_: BOO} );
2334
2335
        $item->update_item_location($action);
2336
2337
        is( $item->location, 'BOO', q{`_ALL_` does the job} );
2338
2339
        t::lib::Mocks::mock_preference( $pref, qq{$location: _BLANK_} );
2340
        $item->location($location)->store();
2341
2342
        $item->update_item_location($action);
2343
        is( $item->location, q{}, q{`_BLANK_` does the job} );
2344
2345
        t::lib::Mocks::mock_preference( $pref, qq{GEN: _BLANK_\n_BLANK_: PROC\n$location: _PERM_} );
2346
2347
        $item->set(
2348
            {
2349
                location           => $location,
2350
                permanent_location =>
2351
                    $permanent_location,    # setting `permanent_location` explicitly because ->store messes with it.
2352
            }
2353
        )->store;
2354
2355
        $item->update_item_location($action);
2356
2357
        is(
2358
            $item->location, $permanent_location,
2359
            q{_PERM_ does the job"}
2360
        );
2361
    }
2362
2363
    $schema->storage->txn_rollback;
2364
};

Return to bug 21159