From dce1eca680d2d5b0489c66c464234042d84f847b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Dec 2021 16:20:59 +0000 Subject: [PATCH] Bug 29719: Unit tests --- t/db_dependent/Koha/Object.t | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 0da041f596..0de1167f91 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -934,11 +934,11 @@ subtest 'prefetch_whitelist() tests' => sub { subtest 'set_or_blank' => sub { - plan tests => 5; + plan tests => 7; $schema->storage->txn_begin; - my $item = $builder->build_sample_item; + my $item = $builder->build_sample_item({ onloan => '2021-01-01'}); my $item_info = $item->unblessed; $item = $item->set_or_blank($item_info); is_deeply($item->unblessed, $item_info, 'set_or_blank assign the correct value if unchanged'); @@ -963,6 +963,16 @@ subtest 'set_or_blank' => sub { $item = $item->set_or_blank($item_info); isnt($item->timestamp, undef, 'set_or_blank should have set timestamp to a correct value'); + # timestamp not null + delete $item_info->{onloan}; + $item = $item->set_or_blank($item_info); + is($item->onloan, '2021-01-01', 'set_or_blank should retain original onloan if none passed'); + + # timestamp not null + $item_info->{onloan} = '2020-01-01'; + $item = $item->set_or_blank($item_info); + is($item->onloan, '2020-01-01', 'set_or_blank should set onloan if passed'); + $schema->storage->txn_rollback; }; -- 2.20.1