Bug 30642: (QA follow-up) Do not rely on script names in modules, add unit test
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Edit: Kyle, stop impersonating John Doe
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e8c232fcf7
)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
This commit is contained in:
parent
65b2c90f58
commit
2b116771f1
3 changed files with 9 additions and 6 deletions
|
@ -3020,7 +3020,7 @@ sub CanBookBeRenewed {
|
|||
|
||||
=head2 AddRenewal
|
||||
|
||||
&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate], [$seen]);
|
||||
&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate], [$seen], [$automatic]);
|
||||
|
||||
Renews a loan.
|
||||
|
||||
|
@ -3049,6 +3049,8 @@ C<$seen> is a boolean flag indicating if the item was seen or not during the ren
|
|||
informs the incrementing of the unseen_renewals column. If this flag is not supplied, we
|
||||
fallback to a true value
|
||||
|
||||
C<$automatic> is a boolean flag indicating the renewal was triggered automatically and not by a person ( librarian or patron )
|
||||
|
||||
=cut
|
||||
|
||||
sub AddRenewal {
|
||||
|
@ -3059,6 +3061,7 @@ sub AddRenewal {
|
|||
my $lastreneweddate = shift || dt_from_string();
|
||||
my $skipfinecalc = shift;
|
||||
my $seen = shift;
|
||||
my $automatic = shift;
|
||||
|
||||
# Fallback on a 'seen' renewal
|
||||
$seen = defined $seen && $seen == 0 ? 0 : 1;
|
||||
|
@ -3068,8 +3071,7 @@ sub AddRenewal {
|
|||
my $issue = $item_object->checkout;
|
||||
my $item_unblessed = $item_object->unblessed;
|
||||
|
||||
my ($package, $filename, $line) = caller;
|
||||
my $renewal_type = $filename =~ m/automatic_renewals.pl/ ? "Automatic" : "Manual";
|
||||
my $renewal_type = $automatic ? "Automatic" : "Manual";
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ while ( my $auto_renew = $auto_renews->next ) {
|
|||
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would';
|
||||
}
|
||||
if ($confirm){
|
||||
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 );
|
||||
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0, 1 );
|
||||
$auto_renew->auto_renew_error(undef)->store;
|
||||
}
|
||||
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
|
||||
|
|
|
@ -4614,7 +4614,7 @@ subtest 'AddRenewal and AddIssuingCharge tests' => sub {
|
|||
};
|
||||
|
||||
subtest 'AddRenewal() adds to renewals' => sub {
|
||||
plan tests => 4;
|
||||
plan tests => 5;
|
||||
|
||||
my $library = $builder->build_object({ class => 'Koha::Libraries' });
|
||||
my $patron = $builder->build_object({
|
||||
|
@ -4631,7 +4631,7 @@ subtest 'AddRenewal() adds to renewals' => sub {
|
|||
is(ref($issue), 'Koha::Checkout', 'Issue added');
|
||||
|
||||
# Renew item
|
||||
my $duedate = AddRenewal( $patron->id, $item->id, $library->id );
|
||||
my $duedate = AddRenewal( $patron->id, $item->id, $library->id, undef, undef, undef, undef, 1 );
|
||||
|
||||
ok( $duedate, "Renewal added" );
|
||||
|
||||
|
@ -4639,6 +4639,7 @@ subtest 'AddRenewal() adds to renewals' => sub {
|
|||
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' );
|
||||
is( $THE_renewal->renewal_type, 'Automatic', 'AddRenewal "automatic" parameter sets renewal type to "Automatic"');
|
||||
};
|
||||
|
||||
subtest 'ProcessOfflinePayment() tests' => sub {
|
||||
|
|
Loading…
Reference in a new issue