Bug 29719: Unit tests
authorNick Clemens <nick@bywatersolutions.com>
Fri, 14 Jan 2022 19:59:07 +0000 (19:59 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 16 May 2022 21:20:09 +0000 (11:20 -1000)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
t/db_dependent/Items.t

index ab0fa8e..3b5c622 100755 (executable)
@@ -1019,7 +1019,7 @@ subtest 'Split subfields in Item2Marc (Bug 21774)' => sub {
 };
 
 subtest 'ModItemFromMarc' => sub {
-    plan tests => 6;
+    plan tests => 7;
     $schema->storage->txn_begin;
 
     my $builder = t::lib::TestBuilder->new;
@@ -1075,6 +1075,24 @@ subtest 'ModItemFromMarc' => sub {
         is( $item->get_from_storage->cn_sort, 'YYY', 'cn_sort has been updated' );
     };
 
+    subtest 'onloan' => sub {
+        plan tests => 3;
+
+        my $item = $builder->build_sample_item;
+        $item->set({ onloan => '2022-03-19' })->store;
+        is( $item->onloan, '2022-03-19', 'init values set are expected' );
+
+        my $marc = C4::Items::Item2Marc( $item->get_from_storage->unblessed, $item->biblionumber );
+        my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' );
+        $marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
+        ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
+        is( $item->get_from_storage->onloan, '2022-03-19', 'onloan has not been updated if not passed' );
+
+        $marc = C4::Items::Item2Marc( { %{$item->unblessed}, onloan => '2022-03-26' }, $item->biblionumber );
+        ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
+        is( $item->get_from_storage->onloan, '2022-03-26', 'onloan has been updated when passed in' );
+    };
+
     subtest 'permanent_location' => sub {
         plan tests => 10;