Bug 28472: (follow-up) add unit test for the case where location = NULL
authorAndreas Roussos <a.roussos@dataly.gr>
Fri, 17 Sep 2021 13:51:51 +0000 (15:51 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Sep 2021 10:32:48 +0000 (12:32 +0200)
This patch adds an extra unit test, to cover the case where the
UpdateItemLocationOnCheckin System Preference is set to "_ALL_: CART"
and the item being returned has no shelving location set.

Test plan:

1) Apply the patch provided earlier
2) prove -v t/db_dependent/Circulation/issue.t
   ...and sign off if all tests pass.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
JD amended patch: use 'is' instead of 'ok'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Circulation/issue.t

index d4fb82b..06c73c4 100755 (executable)
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 47;
+use Test::More tests => 48;
 use DateTime::Duration;
 
 use t::lib::Mocks;
@@ -467,6 +467,23 @@ $item2 = Koha::Items->find( $itemnumber2 );
 ok( $item2->location eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } );
 ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } );
 
+# Bug 28472
+my $itemnumber3 = Koha::Item->new(
+    {
+        biblionumber   => $biblionumber,
+        barcode        => 'barcode_5',
+        itemcallnumber => 'callnumber5',
+        homebranch     => $branchcode_1,
+        holdingbranch  => $branchcode_1,
+        location       => undef,
+        itype          => $itemtype
+    }
+)->store->itemnumber;
+
+t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' );
+AddReturn( 'barcode_5', $branchcode_1 );
+my $item3 = Koha::Items->find( $itemnumber3 );
+is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location value from NULL (i.e. the item has no shelving location set) to 'CART' with setting "_ALL_: CART"} );