From 65494643fa29de88c2f085ce4edcf681108dab46 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 5 Jul 2022 09:14:16 -0300 Subject: [PATCH] Bug 29958: Regression tests Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 3684a53dc328047f5f608d4b3d6b37abcbf30400) Signed-off-by: Lucas Gass (cherry picked from commit 91c4d411157a22bbeb58b43b878705f44c71f1f3) Signed-off-by: Arthur Suzuki (cherry picked from commit 35643f28f91428ca0fa6c1c8c4f5d6b8ba40d13a) Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/Koha/Item.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 161a13b575..6fdf9c3ab3 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Exception; use C4::Biblio; @@ -816,3 +816,32 @@ subtest 'get_transfers' => sub { $schema->storage->txn_rollback; }; + +subtest 'store() tests' => sub { + + plan tests => 1; + + subtest 'dateaccessioned handling' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item; + + ok( defined $item->dateaccessioned, 'dateaccessioned is set' ); + + # reset dateaccessioned on the DB + $schema->resultset('Item')->find({ itemnumber => $item->id })->update({ dateaccessioned => undef }); + $item->discard_changes; + + ok( !defined $item->dateaccessioned ); + + # update something + $item->replacementprice(100)->store->discard_changes; + + ok( !defined $item->dateaccessioned, 'dateaccessioned not set on update if undefined' ); + + $schema->storage->txn_rollback; + }; +}; -- 2.39.5