Bug 17600: Standardize our EXPORT_OK
[srvgit] / t / db_dependent / Circulation / MarkIssueReturned.t
old mode 100644 (file)
new mode 100755 (executable)
index af455e1..e7b1d44
@@ -23,7 +23,7 @@ use Test::Exception;
 use t::lib::Mocks;
 use t::lib::TestBuilder;
 
-use C4::Circulation;
+use C4::Circulation qw( MarkIssueReturned AddIssue );
 use C4::Context;
 use Koha::Checkouts;
 use Koha::Database;
@@ -48,17 +48,9 @@ subtest 'Failure tests' => sub {
             value => { branchcode => $library->branchcode, categorycode => $category->categorycode }
         }
     );
-    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } );
-    my $item       = $builder->build_object(
-        {   class => 'Koha::Items',
-            value  => {
-                homebranch    => $library->branchcode,
-                holdingbranch => $library->branchcode,
-                notforloan    => 0,
-                itemlost      => 0,
-                withdrawn     => 0,
-                biblionumber  => $biblioitem->biblionumber,
-            }
+    my $item = $builder->build_sample_item(
+        {
+            library => $library->branchcode,
         }
     );
 
@@ -95,17 +87,9 @@ subtest 'Anonymous patron tests' => sub {
             value => { branchcode => $library->branchcode, categorycode => $category->categorycode }
         }
     );
-    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } );
-    my $item       = $builder->build_object(
-        {   class => 'Koha::Items',
-            value  => {
-                homebranch    => $library->branchcode,
-                holdingbranch => $library->branchcode,
-                notforloan    => 0,
-                itemlost      => 0,
-                withdrawn     => 0,
-                biblionumber  => $biblioitem->biblionumber,
-            }
+    my $item = $builder->build_sample_item(
+        {
+            library => $library->branchcode,
         }
     );
 
@@ -149,17 +133,9 @@ subtest 'Manually pass a return date' => sub {
             value => { branchcode => $library->branchcode, categorycode => $category->categorycode }
         }
     );
-    my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } );
-    my $item       = $builder->build_object(
-        {   class => 'Koha::Items',
-            value  => {
-                homebranch    => $library->branchcode,
-                holdingbranch => $library->branchcode,
-                notforloan    => 0,
-                itemlost      => 0,
-                withdrawn     => 0,
-                biblionumber  => $biblioitem->biblionumber,
-            }
+    my $item = $builder->build_sample_item(
+        {
+            library => $library->branchcode,
         }
     );
 
@@ -194,6 +170,8 @@ subtest 'Manually pass a return date' => sub {
 subtest 'AutoRemoveOverduesRestrictions' => sub {
     plan tests => 2;
 
+    $schema->storage->txn_begin;
+
     t::lib::Mocks::mock_preference('AutoRemoveOverduesRestrictions', 1);
 
     my $patron = $builder->build_object({ class => 'Koha::Patrons' });
@@ -223,4 +201,6 @@ subtest 'AutoRemoveOverduesRestrictions' => sub {
 
     $debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron->borrowernumber });
     is( scalar @$debarments, 0, 'OVERDUES debarment is removed if patron does not have overdues' );
+
+    $schema->storage->txn_rollback;
 };