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 3175-3177 subtest 'effective_not_for_loan_status() tests' => sub { Link Here
3175
3175
3176
    $schema->storage->txn_rollback;
3176
    $schema->storage->txn_rollback;
3177
};
3177
};
3178
- 
3178
3179
subtest 'effective_bookable() tests' => sub {
3180
3181
    plan tests => 5;
3182
3183
    $schema->storage->txn_begin;
3184
3185
    my $biblio       = $builder->build_sample_biblio;
3186
    my $biblio_itype = Koha::ItemTypes->find( $biblio->itemtype );
3187
    $biblio_itype->bookable(0)->store();
3188
    $biblio_itype->discard_changes;
3189
3190
    my $item_itype = $builder->build_object( { class => 'Koha::ItemTypes' } );
3191
    $item_itype->bookable(1)->store();
3192
    $item_itype->discard_changes;
3193
3194
    my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $item_itype->itemtype } );
3195
    $item->bookable(undef)->store();
3196
    $item->discard_changes;
3197
3198
    isnt( $biblio->itemtype, $item_itype->itemtype, "Biblio level itemtype and item level itemtype does not match" );
3199
3200
    t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
3201
    note("item-level_itypes: 0");
3202
3203
    is(
3204
        $item->effective_bookable, $biblio_itype->bookable,
3205
        '->effective_bookable returns biblio level itemtype bookable value when item bookable is undefined'
3206
    );
3207
3208
    $item->bookable(1)->store();
3209
    $item->discard_changes;
3210
    isnt(
3211
        $item->effective_bookable, $biblio_itype->bookable,
3212
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3213
    );
3214
3215
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
3216
    note("item-level_itypes: 1");
3217
3218
    $item->bookable(undef)->store();
3219
    $item->discard_changes;
3220
    is(
3221
        $item->effective_bookable, $item_itype->bookable,
3222
        '->effective_bookable returns item level itemtype bookable value when item bookable is undefined'
3223
    );
3224
3225
    $item->bookable(0)->store();
3226
    $item->discard_changes;
3227
    isnt(
3228
        $item->effective_bookable, $item_itype->bookable,
3229
        '->effective_bookable returns item specific bookable value when item bookable is defined'
3230
    );
3231
3232
    $schema->storage->txn_rollback;
3233
};

Return to bug 35906