From 38a935143437cc8d1282d18ecc280535473b3d51 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 11 Jul 2024 17:16:32 +0000 Subject: [PATCH] Bug 37316: Add tests --- t/db_dependent/Koha/Item.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 5df382edf5..5b21086e22 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -20,7 +20,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 34; +use Test::More tests => 35; use Test::Exception; use Test::MockModule; @@ -843,6 +843,29 @@ subtest 'request_transfer' => sub { $schema->storage->txn_rollback; }; +subtest 'store check barcodes' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + + my $item = $builder->build_sample_item( + { + biblionumber => $biblio->biblionumber, + } + ); + + $item->barcode("")->store(); + is( $item->barcode, undef, 'Empty string barcodes are treated as undef'); + + $item->barcode("123456789")->store(); + is( $item->barcode, "123456789", 'Non-empty string barcodes are unchanged'); + + $item->barcode(undef)->store(); + is( $item->barcode, undef, 'undef barcodes remain undef'); +}; subtest 'deletion' => sub { plan tests => 15; -- 2.39.2