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

(-)a/t/db_dependent/Circulation/issue.t (-2 / +147 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::NoWarnings;
20
use Test::NoWarnings;
21
use Test::More tests => 66;
21
use Test::More tests => 67;
22
use DateTime::Duration;
22
use DateTime::Duration;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 606-611 subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusO Link Here
606
#
606
#
607
##########################################
607
##########################################
608
608
609
##########################################
610
#
611
# _updateNotForLoanFromYaml
612
#
613
##########################################
614
615
subtest '_updateNotForLoanFromYaml' => sub {
616
    plan tests => 10;
617
    my $itemnumber4 = Koha::Item->new(
618
        {
619
            biblionumber   => $biblionumber,
620
            barcode        => 'barcode_6',
621
            itemcallnumber => 'callnumber6',
622
            homebranch     => $branchcode_1,
623
            holdingbranch  => $branchcode_1,
624
            notforloan     => -1,
625
            itype          => $itemtype,
626
            location       => 'loc1'
627
        },
628
    )->store->itemnumber;
629
630
    t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} );
631
    t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin',  q{} );
632
    $item = Koha::Items->find($itemnumber4);
633
    $item->notforloan(-1)->store;
634
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' );
635
    ok(
636
        $item->notforloan eq -1,
637
        '_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout does not modify value when not enabled'
638
    );
639
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin' );
640
    ok(
641
        $item->notforloan eq -1,
642
        '_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckin does not modify value when not enabled'
643
    );
644
645
    t::lib::Mocks::mock_preference(
646
        'UpdateNotForLoanStatusOnCheckout', q{ _ALL_:
647
        -1: 0
648
    }
649
    );
650
    t::lib::Mocks::mock_preference(
651
        'UpdateNotForLoanStatusOnCheckin', q{ _ALL_:
652
        -2: 0
653
    }
654
    );
655
656
    $item->notforloan(-1)->store;
657
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' );
658
    ok(
659
        $item->notforloan eq 0,
660
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "_ALL_: -1: 0"}
661
    );
662
663
    $item->notforloan(-2)->store;
664
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin' );
665
    ok(
666
        $item->notforloan eq 0,
667
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckin updates notforloan value from -1 to 0 with setting "_ALL_: -1: 0"}
668
    );
669
670
    $item->notforloan(1)->store;
671
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' );
672
    ok(
673
        $item->notforloan eq 1,
674
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout does not update notforloan value from 1 with setting "_ALL_: -1: 0"}
675
    );
676
677
    $item->notforloan(1)->store;
678
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin' );
679
    ok(
680
        $item->notforloan eq 1,
681
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 with setting "_ALL_: -1: 0"}
682
    );
683
684
    t::lib::Mocks::mock_preference(
685
        'UpdateNotForLoanStatusOnCheckout', q{
686
    _ALL_:
687
        -1: 0
688
    } . $itemtype . q{:
689
        -1: 1
690
    }
691
    );
692
    t::lib::Mocks::mock_preference(
693
        'UpdateNotForLoanStatusOnCheckin', q{
694
    _ALL_:
695
        -2: 0
696
    } . $itemtype . q{:
697
        -2: 1
698
    }
699
    );
700
701
    $item->notforloan(-1)->store;
702
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' );
703
    ok(
704
        $item->notforloan eq 1,
705
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout uses the most specific rule to update notforloan }
706
    );
707
708
    $item->notforloan(-2)->store;
709
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin' );
710
    ok(
711
        $item->notforloan eq 1,
712
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout uses the most specific rule to update notforloan }
713
    );
714
715
    t::lib::Mocks::mock_preference(
716
        'UpdateNotForLoanStatusOnCheckout', q{
717
    _ALL_:
718
        -1: 0
719
    NOT_} . $itemtype . q{:
720
        -1: 1
721
    }
722
    );
723
    t::lib::Mocks::mock_preference(
724
        'UpdateNotForLoanStatusOnCheckin', q{
725
    _ALL_:
726
        -2: 0
727
    NOT_} . $itemtype . q{:
728
        -2: 1
729
    }
730
    );
731
732
    $item->notforloan(-1)->store;
733
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' );
734
    ok(
735
        $item->notforloan eq 0,
736
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckout uses the default rule (_ALL_) if no rule matches the itype}
737
    );
738
739
    $item->notforloan(-2)->store;
740
    C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckin' );
741
    ok(
742
        $item->notforloan eq 0,
743
        q{_updateNotForLoanFromYaml: UpdateNotForLoanStatusOnCheckin uses the default rule (_ALL_) if no rule matches the itype}
744
    );
745
746
    $item->delete;
747
};
748
749
##########################################
750
#
751
# END _updateNotForLoanFromYaml
752
#
753
##########################################
754
609
my $itemnumber2 = Koha::Item->new(
755
my $itemnumber2 = Koha::Item->new(
610
    {
756
    {
611
        biblionumber   => $biblionumber,
757
        biblionumber   => $biblionumber,
612
- 

Return to bug 35292