@@ -, +, @@ --- t/db_dependent/Koha/Object.t | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/t/db_dependent/Koha/Object.t +++ a/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; }; --