Bug 21999: Update Tests to reflect new return value of AddIssue
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 14 Dec 2018 15:03:46 +0000 (15:03 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 11 Jan 2019 13:05:52 +0000 (13:05 +0000)
Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
t/db_dependent/Circulation.t
t/db_dependent/Circulation/issue.t
t/db_dependent/Letters/TemplateToolkit.t

index dfa4a21..d051634 100755 (executable)
@@ -1217,7 +1217,7 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
     set_userenv($holdingbranch);
 
     my $issue = AddIssue( $patron_1->unblessed, $item->{barcode} );
-    is( ref($issue), 'Koha::Schema::Result::Issue' );    # FIXME Should be Koha::Checkout
+    is( ref($issue), 'Koha::Checkout' );    # FIXME Should be Koha::Checkout
 
     my ( $error, $question, $alerts );
 
@@ -1310,7 +1310,7 @@ subtest 'AddIssue & AllowReturnToBranch' => sub {
 
     set_userenv($holdingbranch);
 
-    my $ref_issue = 'Koha::Schema::Result::Issue'; # FIXME Should be Koha::Checkout
+    my $ref_issue = 'Koha::Checkout'; # FIXME Should be Koha::Checkout
     my $issue = AddIssue( $patron_1, $item->{barcode} );
 
     my ( $error, $question, $alerts );
index 63e9488..9dff999 100644 (file)
@@ -170,13 +170,13 @@ $sth->execute;
 my $countissue = $sth -> fetchrow_array;
 is ($countissue ,0, "there is no issue");
 my $issue1 = C4::Circulation::AddIssue( $borrower_1, $barcode_1, $daysago10,0, $today, '' );
-is( ref $issue1, 'Koha::Schema::Result::Issue',
-       'AddIssue returns a Koha::Schema::Result::Issue object' );
+is( ref $issue1, 'Koha::Checkout',
+       'AddIssue returns a Koha::Checkout object' );
 my $datedue1 = dt_from_string( $issue1->date_due() );
 like(
     $datedue1,
     qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
-    "Koha::Schema::Result::Issue->date_due() returns a date"
+    "Koha::Checkout->date_due() returns a date"
 );
 my $issue_id1 = $issue1->issue_id;
 
index 49301eb..502e429 100644 (file)
@@ -653,11 +653,11 @@ EOF
         reset_template( { template => $template, code => $code, module => 'circulation' } );
 
         my $checkout = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
-        $checkout->set_columns( { timestamp => $now, issuedate => $one_minute_ago } )->update; # FIXME $checkout is a Koha::Schema::Result::Issues, must be a Koha::Checkout
+        $checkout->set( { timestamp => $now, issuedate => $one_minute_ago } )->store;
         my $first_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
 
         $checkout = C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
-        $checkout->set_columns( { timestamp => $now, issuedate => $now } )->update;
+        $checkout->set( { timestamp => $now, issuedate => $now } )->store;
         my $yesterday = dt_from_string->subtract( days => 1 );
         C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
         my $second_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
@@ -713,11 +713,11 @@ EOF
         reset_template( { template => $tt_template, code => $code, module => 'circulation' } );
 
         $checkout = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
-        $checkout->set_columns( { timestamp => $now, issuedate => $one_minute_ago } )->update;
+        $checkout->set( { timestamp => $now, issuedate => $one_minute_ago } )->store;
         my $first_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
 
         $checkout = C4::Circulation::AddIssue( $patron, $item2->{barcode} ); # Add a second checkout
-        $checkout->set_columns( { timestamp => $now, issuedate => $now } )->update;
+        $checkout->set( { timestamp => $now, issuedate => $now } )->store;
         C4::Circulation::AddIssue( $patron, $item3->{barcode}, $yesterday ); # Add an overdue
         my $second_tt_slip = C4::Members::IssueSlip( $branchcode, $patron->{borrowernumber} );
 
@@ -776,9 +776,9 @@ EOF
         my $issue1 = C4::Circulation::AddIssue( $patron, $item1->{barcode} ); # Add a first checkout
         my $issue2 = C4::Circulation::AddIssue( $patron, $item2->{barcode}, $yesterday ); # Add an first overdue
         my $issue3 = C4::Circulation::AddIssue( $patron, $item3->{barcode}, $two_days_ago ); # Add an second overdue
-        $issue1 = Koha::Checkout->_new_from_dbic( $issue1 )->unblessed; # ->unblessed should be enough but AddIssue does not return a Koha::Checkout object
-        $issue2 = Koha::Checkout->_new_from_dbic( $issue2 )->unblessed;
-        $issue3 = Koha::Checkout->_new_from_dbic( $issue3 )->unblessed;
+        $issue1 = $issue1->unblessed;
+        $issue2 = $issue2->unblessed;
+        $issue3 = $issue3->unblessed;
 
         # For items.content
         my @item_fields = qw( date_due title barcode author itemnumber );