From f27c11341e2f4d0a053873abbb345a26adc5385a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 28 Apr 2022 11:35:54 +0100 Subject: [PATCH] Bug 30275: Add unit tests for AddRenewal addition This patch adds a test for the AddRenewal addition that creates Renewal lines. Test plan 1) Run the unit tests and confirm it passes Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Circulation.t | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index a7d5eaa104..e9c8bfa84f 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -4410,6 +4410,34 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub { }; +subtest 'AddRenewal() adds to renewals' => sub { + plan tests => 4; + + my $library = $builder->build_object({ class => 'Koha::Libraries' }); + my $patron = $builder->build_object({ + class => 'Koha::Patrons', + value => { branchcode => $library->id } + }); + + my $item = $builder->build_sample_item(); + + set_userenv( $library->unblessed ); + + # Check the item out + my $issue = AddIssue( $patron->unblessed, $item->barcode ); + is(ref($issue), 'Koha::Checkout', 'Issue added'); + + # Renew item + my $duedate = AddRenewal( $patron->id, $item->id, $library->id ); + + ok( $duedate, "Renewal added" ); + + my $renewals = Koha::Checkouts::Renewals->search({ checkout_id => $issue->issue_id }); + is($renewals->count, 1, 'One renewal added'); + my $THE_renewal = $renewals->next; + is( $THE_renewal->renewer_id, C4::Context->userenv->{'number'}, 'Renewer recorded from context' ); +}; + subtest 'ProcessOfflinePayment() tests' => sub { plan tests => 4; -- 2.20.1