Bug 19915: Don't delete in tests
authorNick Clemens <nick@bywatersolutions.com>
Thu, 1 Nov 2018 13:11:16 +0000 (13:11 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 11 Feb 2019 13:39:21 +0000 (13:39 +0000)
https://bugs.koha-community.org/show_bug.cgi?id=19905

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 9961e2c08f8dba0896ed4f6bfa6a7befebd28d5d)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Items/GetItemsForInventory.t

index c8d2594..fcbcc71 100755 (executable)
@@ -143,7 +143,6 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su
     plan tests => 1;
 
     my $builder = t::lib::TestBuilder->new;
-    Koha::Items->delete;
 
     my $class_rule = $builder->build({
         source => 'ClassSortRule',
@@ -155,6 +154,14 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su
             class_sort_rule => $class_rule->{class_sort_rule},
         }
     });
+
+    #Find if we have any items in our test range before we start
+    my( undef, $pre_item_count) = GetItemsForInventory({
+        maxlocation => 'GT100',
+        minlocation => 'GT90',
+        class_source => $class_source->{cn_source},
+    });
+
     my $item_1 = $builder->build({
             source => 'Item',
             value  => {
@@ -168,7 +175,7 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su
         minlocation => 'GT90',
         class_source => $class_source->{cn_source},
     });
-    is($item_count,1,"We should return GT95 as between GT90 and GT100");
+    is($item_count,$pre_item_count + 1,"We should return GT95 as between GT90 and GT100");
     $schema->storage->txn_rollback;
 
 };