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

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

Return to bug 35292