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

(-)a/t/db_dependent/Koha/Item.t (-2 / +57 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 => 37;
23
use Test::More tests => 38;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 3239-3241 subtest 'effective_not_for_loan_status() tests' => sub { Link Here
3239
3239
3240
    $schema->storage->txn_rollback;
3240
    $schema->storage->txn_rollback;
3241
};
3241
};
3242
- 
3242
3243
subtest 'effective_bookable() tests' => sub {
3244
3245
    plan tests => 5;
3246
3247
    $schema->storage->txn_begin;
3248
3249
    my $biblio       = $builder->build_sample_biblio;
3250
    my $biblio_itype = Koha::ItemTypes->find( $biblio->itemtype );
3251
    $biblio_itype->bookable(0)->store();
3252
    $biblio_itype->discard_changes;
3253
3254
    my $item_itype = $builder->build_object( { class => 'Koha::ItemTypes' } );
3255
    $item_itype->bookable(1)->store();
3256
    $item_itype->discard_changes;
3257
3258
    my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $item_itype->itemtype } );
3259
    $item->bookable(undef)->store();
3260
    $item->discard_changes;
3261
3262
    isnt( $biblio->itemtype, $item_itype->itemtype, "Biblio level itemtype and item level itemtype does not match" );
3263
3264
    t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
3265
    note("item-level_itypes: 0");
3266
3267
    is(
3268
        $item->effective_bookable, $biblio_itype->bookable,
3269
        '->effective_bookable returns biblio level itemtype bookable value when item bookable is undefined'
3270
    );
3271
3272
    $item->bookable(1)->store();
3273
    $item->discard_changes;
3274
    isnt(
3275
        $item->effective_bookable, $biblio_itype->bookable,
3276
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3277
    );
3278
3279
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
3280
    note("item-level_itypes: 1");
3281
3282
    $item->bookable(undef)->store();
3283
    $item->discard_changes;
3284
    is(
3285
        $item->effective_bookable, $item_itype->bookable,
3286
        '->effective_bookable returns item level itemtype bookable value when item bookable is undefined'
3287
    );
3288
3289
    $item->bookable(0)->store();
3290
    $item->discard_changes;
3291
    isnt(
3292
        $item->effective_bookable, $item_itype->bookable,
3293
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3294
    );
3295
3296
    $schema->storage->txn_rollback;
3297
};

Return to bug 35906