Bug 24377: Unit test

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit cf331e0b34)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2020-01-16 13:09:50 +00:00 committed by Lucas Gass
parent 180b20a6b8
commit 4bb7ecc793
1 changed files with 17 additions and 6 deletions

View File

@ -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' );
};