Bug 18664: Make IssueSlip returns if params are not valid
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 23 May 2017 19:33:17 +0000 (16:33 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 29 May 2017 02:26:23 +0000 (22:26 -0400)
Problem raised by bug 17762: IssueSlip should return if the params are
not valid.
The tests contain 2 FIXME to highlight this problem already, it's time
to fix them.

Note that, theoretically, this change may produce software error. Indeed
the caller expecting a hashref (letter) will access the "content" key.
But that should not happen.

Test plan:
Tests must return green

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Members.pm
t/db_dependent/Members/IssueSlip.t

index b61f0b1..6527c79 100644 (file)
@@ -1174,6 +1174,7 @@ sub IssueSlip {
     #return unless $borrowernumber;
 
     my $patron = Koha::Patrons->find( $borrowernumber );
+    return unless $patron;
 
     my @issues = @{ GetPendingIssues($borrowernumber) };
 
index c8135bc..d161602 100644 (file)
@@ -397,20 +397,9 @@ EOS
 };
 
 subtest 'bad calls' => sub {
-    plan tests => 2;
-    AddIssue( $borrower, $barcode1, $today, undef, $yesterday );
+    plan tests => 1;
     my $slip = IssueSlip();
-    isnt( $slip, undef, 'IssueSlip should return if no param passed FIXME, should return undef' );
-    my $empty_slip = <<EOS;
-Checked out:
-
-
-Overdues:
-
-EOS
-
-    $slip = IssueSlip(undef, $borrowernumber+1);
-    is( $slip->{content}, $empty_slip, 'IssueSlip should not return an empty slip if the borrowernumber passed in param does not exist. But it is what it does for now (FIXME)' );
+    is( $slip, undef, 'IssueSlip should return if no valid borrowernumber is passed' );
 };
 
 $schema->storage->txn_rollback;