Bug 25297: Regression tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Apr 2020 21:55:32 +0000 (18:55 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 1 May 2020 07:16:31 +0000 (08:16 +0100)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Koha/Acquisition/Order.t

index f62f3eb..2b00e3c 100644 (file)
@@ -285,7 +285,7 @@ subtest 'duplicate_to | add_item' => sub {
 
 subtest 'current_item_level_holds() tests' => sub {
 
-    plan tests => 3;
+    plan tests => 5;
 
     $schema->storage->txn_begin;
 
@@ -334,16 +334,23 @@ subtest 'current_item_level_holds() tests' => sub {
         }
     );
 
-    is( $order->current_item_level_holds, undef, 'Returns undef if no linked biblio');
+    my $holds = $order->current_item_level_holds;
+
+    is( ref($holds), 'Koha::Holds', 'Koha::Holds iterator returned if no linked biblio' );
+    is( $holds->count, 0, 'Count is 0 if no linked biblio' );
 
     $order->set({ biblionumber => $biblio->biblionumber })->store->discard_changes;
 
-    is( $order->current_item_level_holds, undef, 'Returns undef if no linked items');
+    $holds = $order->current_item_level_holds;
+
+    is( ref($holds), 'Koha::Holds', 'Koha::Holds iterator returned if no linked items' );
+    is( $holds->count, 0, 'Count is 0 if no linked items' );
 
     $order->add_item( $item_2->itemnumber );
     $order->add_item( $item_3->itemnumber );
 
-    is( $order->current_item_level_holds->count, 1, 'Only current (not future) holds are returned');
+    $holds = $order->current_item_level_holds;
+    is( $holds->count, 1, 'Only current (not future) holds are returned');
 
     $schema->storage->txn_rollback;
 };