Bug 19915: Add unit test to GetItemsForInventory.t
authorNick Clemens <nick@bywatersolutions.com>
Thu, 4 Jan 2018 14:53:14 +0000 (14:53 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 11 Feb 2019 13:37:41 +0000 (13:37 +0000)
prove -v t/db_dependent/Items/GetItemsForInventory.t

Signed-off-by: Anne-Claire Bernaudin <anne-claire.bernaudin@univ-rennes1.fr>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Moved the betwen typo edit back here.

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 186209875a4951b15faded3f8c47eba71716c7af)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Items/GetItemsForInventory.t

index fddea80..d2ddd2e 100755 (executable)
 
 use Modern::Perl;
 
-use Test::More tests => 7;
+use Test::More tests => 8;
 use t::lib::TestBuilder;
 
 use List::MoreUtils qw( any none );
 
 use C4::Biblio qw(AddBiblio);
 use C4::Reserves;
+use C4::ClassSource;
 use Koha::AuthorisedValues;
 use Koha::Biblios;
 use Koha::Database;
@@ -59,6 +60,7 @@ subtest 'Old version is unchanged' => sub {
     $schema->storage->txn_rollback;
 };
 
+<<<<<<< HEAD
 subtest 'Skip items with waiting holds' => sub {
 
     plan tests => 6;
@@ -125,6 +127,46 @@ subtest 'Skip items with waiting holds' => sub {
         'Item on hold skipped, no one matches' );
 
     $schema->storage->txn_rollback;
+=======
+$dbh->rollback;
+$dbh->{AutoCommit} = 1;
+
+subtest 'Use cn_sort rather than callnumber to determine correct location' => sub {
+
+    plan tests => 1;
+    my $builder = t::lib::TestBuilder->new;
+    my $schema  = Koha::Database->new->schema;
+    $schema->storage->txn_begin;
+    $builder->schema->resultset( 'Issue' )->delete_all;
+    $builder->schema->resultset( 'Item' )->delete_all;
+
+    my $class_rule = $builder->build({
+        source => 'ClassSortRule',
+        value => { sort_routine => "LCC" }
+    });
+    my $class_source = $builder->build({
+        source => 'ClassSource',
+        value => {
+            class_sort_rule => $class_rule->{class_sort_rule},
+        }
+    });
+    my $item_1 = $builder->build({
+            source => 'Item',
+            value  => {
+                itemcallnumber => 'GT95',
+                cn_sort => GetClassSort($class_source->{cn_source},undef,'GT95'),
+            }
+    });
+
+    my( undef, $item_count) = GetItemsForInventory({
+        maxlocation => 'GT100',
+        minlocation => 'GT90',
+        class_source => $class_source->{cn_source},
+    });
+    is($item_count,1,"We should return GT95 as between GT90 and GT100");
+    $schema->storage->txn_rollback;
+
+>>>>>>> Bug 19915: Add unit test to GetItemsForInventory.t
 };
 
 sub OldWay {