From 8d7e10bbe0d126dadf0ea785b340fe0740d996c9 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 22 Oct 2025 11:20:50 +0300 Subject: [PATCH] Bug 29326: Add more tests Tests for more complex preference values To test: 1. prove t/db_dependent/Koha/Item.t --- t/db_dependent/Koha/Item.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index c64c72e45fb..a2b35df93cd 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -3356,12 +3356,13 @@ subtest 'current_branchtransfers relationship' => sub { subtest 'location_update_trigger() tests' => sub { - plan tests => 12; + plan tests => 18; $schema->storage->txn_begin; my $location = 'YA'; my $permanent_location = 'HEY'; + my $another_location = 'SAUNA'; foreach my $action (qw{ checkin checkout }) { @@ -3416,6 +3417,20 @@ subtest 'location_update_trigger() tests' => sub { $item->location, $permanent_location, q{_PERM_ does the job"} ); + + t::lib::Mocks::mock_preference( $pref, qq{$location: $another_location\n_BLANK_: $permanent_location\n_DEFAULT_: $location } ); + $item->location($location)->store; + $item->location_update_trigger($action); + is( $item->location, $another_location, qq{'location' value set from '$location' to '$another_location' with setting `$location: $another_location`} ); + + $item->location('')->store; + $item->location_update_trigger($action); + is( $item->location, $permanent_location, qq{'location' value set from '' to '$permanent_location' with setting `_BLANK_: $permanent_location`} ); + + $item->location($permanent_location)->store; + $item->location_update_trigger($action); + is( $item->location, $location, qq{'location' value set from '$permanent_location' to '$location' with setting `_DEFAULT_: $location`} ); + } $schema->storage->txn_rollback; -- 2.34.1