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

(-)a/t/db_dependent/Koha/Item.t (-2 / +51 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 => 34;
23
use Test::More tests => 35;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 2640-2642 subtest 'check_booking tests' => sub { Link Here
2640
2640
2641
    $schema->storage->txn_rollback;
2641
    $schema->storage->txn_rollback;
2642
};
2642
};
2643
- 
2643
2644
subtest 'not_for_loan() tests' => sub {
2645
2646
    plan tests => 5;
2647
2648
    $schema->storage->txn_begin;
2649
2650
    my $biblio       = $builder->build_sample_biblio;
2651
    my $biblio_itype = Koha::ItemTypes->find( $biblio->itemtype );
2652
    $biblio_itype->notforloan(3)->store();
2653
2654
    my $item_itype = $builder->build_object( { class => 'Koha::ItemTypes' } );
2655
    $item_itype->notforloan(2)->store();
2656
2657
    my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $item_itype->itemtype } );
2658
    $item->notforloan(1)->store();
2659
2660
    isnt( $biblio->itemtype, $item_itype->itemtype, "Biblio level itemtype and item level itemtype does not match" );
2661
2662
    t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
2663
    diag("item-level_itypes: 0");
2664
2665
    is(
2666
        $item->not_for_loan, $item->notforloan,
2667
        '->not_for_loan returns item specific notforloan value when defined and non-zero'
2668
    );
2669
2670
    $item->notforloan(0)->store();
2671
    is(
2672
        $item->not_for_loan, $biblio_itype->notforloan,
2673
        '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0'
2674
    );
2675
2676
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
2677
    diag("item-level_itypes: 1");
2678
2679
    $item->notforloan(1)->store();
2680
    is(
2681
        $item->not_for_loan, $item->notforloan,
2682
        '->not_for_loan returns item specific notforloan value when defined and non-zero'
2683
    );
2684
2685
    $item->notforloan(0)->store();
2686
    is(
2687
        $item->not_for_loan, $item_itype->notforloan,
2688
        '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0'
2689
    );
2690
2691
    $schema->storage->txn_rollback;
2692
};

Return to bug 28762