From 43ad66fb07d5f96ac725a8f21a1ef67a53c0461d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 3 Nov 2017 13:27:12 -0300 Subject: [PATCH] Bug 10748: Add tests Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- t/db_dependent/Circulation/Returns.t | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t index d82e78a59d..de941f22e4 100644 --- a/t/db_dependent/Circulation/Returns.t +++ b/t/db_dependent/Circulation/Returns.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::MockModule; use Test::Warn; @@ -332,3 +332,32 @@ subtest 'Handle ids duplication' => sub { is( Koha::Checkouts->find( $issue_id )->issue_id, $issue_id, 'The issues entry should not have been removed' ); }; +subtest 'BlockReturnOfLostItems' => sub { + plan tests => 3; + my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); + my $item = $builder->build_object( + { + class => 'Koha::Items', + value => { + biblionumber => $biblio->biblionumber, + notforloan => 0, + itemlost => 0, + withdrawn => 0, + } + } + ); + my $patron = $builder->build_object({class => 'Koha::Patrons'}); + my $checkout = AddIssue( $patron->unblessed, $item->barcode ); + + # Mark the item as lost + ModItem({itemlost => 1}, $biblio->biblionumber, $item->itemnumber); + + t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 1); + my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode); + is( $doreturn, 0, "With BlockReturnOfLostItems, a checkin of a lost item should be blocked"); + is( $messages->{WasLost}, 1, "... and the WasLost flag should be set"); + + t::lib::Mocks::mock_preference('BlockReturnOfLostItems', 0); + ( $doreturn, $messages, $issue ) = AddReturn($item->barcode); + is( $doreturn, 1, "Without BlockReturnOfLostItems, a checkin of a lost item should not be blocked"); +}; -- 2.39.5