From 4bb7ecc7939f7d9f5f951f6302a779b57e0af729 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Jan 2020 13:09:50 +0000 Subject: [PATCH] Bug 24377: Unit test Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit cf331e0b3480fdf35947d887843f8bee6cd894e5) Signed-off-by: Lucas Gass --- t/db_dependent/Circulation.t | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index d0a6006fab..83eee84714 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2958,8 +2958,7 @@ subtest 'AddReturn should clear items.onloan for unissued items' => sub { subtest 'AddRenewal and AddIssuingCharge tests' => sub { - plan tests => 13; - + plan tests => 12; t::lib::Mocks::mock_preference('item-level_itypes', 1); @@ -3041,10 +3040,22 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); - $line = $lines->next; - is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); - is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); - is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); + t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); + + $context = Test::MockModule->new('C4::Context'); + $context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) + + $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); + $old_log_size = Koha::ActionLogs->count( \%params_renewal ); + my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); + $sth->execute($item->id, $library->id); + my ($old_stats_size) = $sth->fetchrow_array; + AddRenewal( $patron->id, $item->id, $library->id ); + $new_log_size = Koha::ActionLogs->count( \%params_renewal ); + $sth->execute($item->id, $library->id); + my ($new_stats_size) = $sth->fetchrow_array; + is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); + is( $new_stats_size, $old_stats_size + 1, 'renew statistic successfully added with passed branch' ); }; -- 2.39.2