From a686115efa88a36077cd9f3e1095e0fdcb215a0e Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Fri, 6 Mar 2026 15:50:16 +0000 Subject: [PATCH] Bug 14962: (QA follow-up) Update tests for Koha::Item This patch adds new tests for our new effective methods, meaning they are now being examined for future regressions or breakage. Sponsored-by: ByWater Solutions --- t/db_dependent/Koha/Item.t | 69 +++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index e0405a6a265..4f5d2bbb9bb 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -21,7 +21,7 @@ use Modern::Perl; use utf8; use Test::NoWarnings; -use Test::More tests => 42; +use Test::More tests => 46; use Test::Exception; use Test::MockModule; use Test::Warn; @@ -3923,6 +3923,73 @@ subtest 'effective_bookable() tests' => sub { $schema->storage->txn_rollback; }; +subtest 'effective_homebranch() test' => sub { + plan tests => 3; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item(); + + is( $item->homebranch, $item->effective_homebranch, 'homebranch() and effective_homebranch() matches by default' ); + is_deeply( + $item->home_branch, $item->effective_home_branch, + 'home_branch() and effective_home_branch() matches by default' + ); + is_deeply( + $item->home_library, $item->effective_home_library, + 'home_library() and effective_home_library() matches by default' + ); + + $schema->storage->txn_rollback; +}; + +subtest 'effective_holdingbranch() test' => sub { + plan tests => 3; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item(); + + is( + $item->holdingbranch, $item->effective_holdingbranch, + 'holdingbranch() and effective_holdingbranch() matches by default' + ); + is_deeply( + $item->holding_branch, $item->effective_holding_branch, + 'holding_branch() and effective_holding_branch() matches by default' + ); + is_deeply( + $item->holding_library, $item->effective_holding_library, + 'holding_library() and effective_holding_library() matches by default' + ); + + $schema->storage->txn_rollback; +}; + +subtest 'effective_collection_code() test' => sub { + plan tests => 1; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item(); + + is( $item->ccode, $item->effective_collection_code, 'ccode() and effective_collection_code() matches by default' ); + + $schema->storage->txn_rollback; +}; + +subtest 'effective_itemtype() test' => sub { + plan tests => 1; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item(); + + is( $item->itype, $item->effective_itemtype, 'itype() and effective_itemtype() matches by default' ); + + $schema->storage->txn_rollback; +}; + subtest 'holds_fee() tests' => sub { plan tests => 3; -- 2.50.1 (Apple Git-155)