From 2146523b2865497fe904d1e182a5193a80752b86 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 6 May 2020 10:33:35 +0100 Subject: [PATCH] Bug 25261: (QA follow-up) Add unit tests Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- t/db_dependent/Circulation.t | 53 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 8ea7ac50eb..154e543459 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 48; +use Test::More tests => 51; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -3544,6 +3544,57 @@ subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub { $itemtype->rentalcharge_daily('0')->store; }; +subtest 'CanBookBeIssued & CircConfirmItemParts' => sub { + plan tests => 1; + + t::lib::Mocks::mock_preference('CircConfirmItemParts', 1); + + my $library = + $builder->build_object( { class => 'Koha::Libraries' } )->store; + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { categorycode => $patron_category->{categorycode} } + } + )->store; + + my $itemtype = $builder->build_object( + { + class => 'Koha::ItemTypes', + value => { + notforloan => 0, + rentalcharge => 0, + rentalcharge_daily => 0 + } + } + ); + + my $biblioitem = $builder->build( { source => 'Biblioitem' } ); + my $item = $builder->build_object( + { + class => 'Koha::Items', + value => { + homebranch => $library->id, + holdingbranch => $library->id, + notforloan => 0, + itemlost => 0, + withdrawn => 0, + itype => $itemtype->id, + biblionumber => $biblioitem->{biblionumber}, + biblioitemnumber => $biblioitem->{biblioitemnumber}, + materials => 'includes DVD', + } + } + )->store; + + my ( $issuingimpossible, $needsconfirmation ); + my $dt_from = dt_from_string(); + my $dt_due = $dt_from->clone->add( days => 3 ); + + ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); + is_deeply( $needsconfirmation, { additional_materials => 'includes DVD' }, 'Item needs confirmation of additional parts' ); +}; + subtest 'Do not return on renewal (LOST charge)' => sub { plan tests => 1; -- 2.11.4.GIT