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

(-)a/t/db_dependent/Koha/Items.t (-2 / +50 lines)
Lines 136-142 subtest 'store' => sub { Link Here
136
    };
136
    };
137
137
138
    subtest '_lost_found_trigger' => sub {
138
    subtest '_lost_found_trigger' => sub {
139
        plan tests => 6;
139
        plan tests => 7;
140
140
141
        t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 );
141
        t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 );
142
        t::lib::Mocks::mock_preference( 'WhenLostForgiveFine',          0 );
142
        t::lib::Mocks::mock_preference( 'WhenLostForgiveFine',          0 );
Lines 758-763 subtest 'store' => sub { Link Here
758
            is( $item->{_refunded}, undef, 'No refund triggered' );
758
            is( $item->{_refunded}, undef, 'No refund triggered' );
759
759
760
        };
760
        };
761
762
        subtest 'Continue when userenv is not set' => sub {
763
            plan tests => 1;
764
765
            my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
766
            my $barcode            = 'KD123456795';
767
            my $replacement_amount = 100;
768
            my $processfee_amount  = 20;
769
770
            my $item_type = $builder->build_object(
771
                {
772
                    class => 'Koha::ItemTypes',
773
                    value => {
774
                        notforloan         => undef,
775
                        rentalcharge       => 0,
776
                        defaultreplacecost => undef,
777
                        processfee         => 0,
778
                        rentalcharge_daily => 0,
779
                    }
780
                }
781
            );
782
            my $item = Koha::Item->new(
783
                {
784
                    biblionumber     => $biblio->biblionumber,
785
                    homebranch       => $library->branchcode,
786
                    holdingbranch    => $library->branchcode,
787
                    barcode          => $barcode,
788
                    replacementprice => $replacement_amount,
789
                    itype            => $item_type->itemtype
790
                },
791
            )->store;
792
793
            my $issue =
794
              C4::Circulation::AddIssue( $patron->unblessed, $barcode );
795
796
            # Simulate item marked as lost
797
            $item->itemlost(1)->store;
798
            C4::Circulation::LostItem( $item->itemnumber, 1 );
799
800
            # Unset the userenv
801
            C4::Context->_new_userenv(undef);
802
803
            # Simluate item marked as found
804
            $item->itemlost(0)->store;
805
            is( $item->{_refunded}, 1, 'No refund triggered' );
806
807
        };
761
    };
808
    };
762
};
809
};
763
810
Lines 815-820 subtest 'biblioitem' => sub { Link Here
815
    is( $biblioitem->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblioitem should return the correct biblioitem' );
862
    is( $biblioitem->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblioitem should return the correct biblioitem' );
816
};
863
};
817
864
865
# Restore userenv
866
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
818
subtest 'checkout' => sub {
867
subtest 'checkout' => sub {
819
    plan tests => 5;
868
    plan tests => 5;
820
    my $item = Koha::Items->find( $new_item_1->itemnumber );
869
    my $item = Koha::Items->find( $new_item_1->itemnumber );
821
- 

Return to bug 18501