Bug 17680: C4::Circulation - Remove GetItemIssue, simple calls
[koha.git] / t / db_dependent / Circulation / issue.t
index c3d4d8d..312f6a9 100644 (file)
@@ -45,9 +45,6 @@ can_ok(
       AddReturn
       GetBiblioIssues
       GetIssuingCharges
-      GetIssuingRule
-      GetItemIssue
-      GetItemIssues
       GetOpenIssue
       GetRenewCount
       GetUpcomingDueIssues
@@ -68,6 +65,9 @@ $dbh->do(q|DELETE FROM branches|);
 $dbh->do(q|DELETE FROM categories|);
 $dbh->do(q|DELETE FROM accountlines|);
 $dbh->do(q|DELETE FROM issuingrules|);
+$dbh->do(q|DELETE FROM reserves|);
+$dbh->do(q|DELETE FROM old_reserves|);
+$dbh->do(q|DELETE FROM statistics|);
 
 # Generate sample datas
 my $itemtype = $builder->build(
@@ -77,6 +77,7 @@ my $itemtype = $builder->build(
 )->{itemtype};
 my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
 my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
+my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode};
 my $categorycode = $builder->build({
         source => 'Category',
         value => { enrolmentfee => undef }
@@ -160,6 +161,11 @@ my @USERENV = (
     $branchcode_1, 'email@example.org'
 );
 
+my @USERENV_DIFFERENT_LIBRARY = (
+    $borrower_id1, 'test', 'MASTERTEST', 'firstname', $branchcode_3,
+    $branchcode_3, 'email@example.org'
+);
+
 
 C4::Context->_new_userenv('DUMMY_SESSION_ID');
 C4::Context->set_userenv(@USERENV);
@@ -207,27 +213,25 @@ $sth->execute;
 $countaccount = $sth -> fetchrow_array;
 is ($countaccount,1,"1 accountline has been added");
 
-#Test AddRenewal
-my $datedue3 =
-  AddRenewal( $borrower_id1, $item_id1, $branchcode_1,
-    $datedue1, $daysago10 );
+# Test AddRenewal
+
+# Let's renew this one at a different library for statistical purposes to test Bug 17781
+C4::Context->set_userenv(@USERENV_DIFFERENT_LIBRARY);
+my $datedue3 = AddRenewal( $borrower_id1, $item_id1, $branchcode_1, $datedue1, $daysago10 );
+C4::Context->set_userenv(@USERENV);
+
 like(
     $datedue3,
     qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
     "AddRenewal returns a date"
 );
 
-#Test GetBiblioIssues
-is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
+my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 );
+ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" );
 
-#Test GetItemIssue
-#FIXME : As the issues are not correctly added in the database, these tests don't work correctly
-is(GetItemIssue,undef,"Without parameter GetItemIssue returns undef");
-#is(GetItemIssue($item_id1),{},"Item1's issues");
 
-#Test GetItemIssues
-#FIXME: this routine currently doesn't work be
-#is_deeply (GetItemIssues,{},"Without parameter, GetItemIssue returns all the issues");
+#Test GetBiblioIssues
+is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
 
 #Test GetOpenIssue
 is( GetOpenIssue(), undef, "Without parameter GetOpenIssue returns undef" );
@@ -242,7 +246,7 @@ my $issue3 = C4::Circulation::AddIssue( $borrower_1, $barcode_1 );
 @renewcount = C4::Circulation::GetRenewCount();
 is_deeply(
     \@renewcount,
-    [ 0, undef, 0 ], # FIXME Need to be fixed
+    [ 0, undef, 0 ], # FIXME Need to be fixed, see FIXME in GetRenewCount
     "Without issuing rules and without parameter, GetRenewCount returns renewcount = 0, renewsallowed = undef, renewsleft = 0"
 );
 @renewcount = C4::Circulation::GetRenewCount(-1);