From ada3b5fcfa7f40e5d8514f763b729aa8de197995 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 4 Dec 2023 20:09:50 -1000 Subject: [PATCH] Bug 32029: (follow-up) unit test Signed-off-by: matthias le gac --- .../Items/AutomaticItemModificationByAge.t | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t index 60507a478a..51b98f9489 100755 --- a/t/db_dependent/Items/AutomaticItemModificationByAge.t +++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 19; +use Test::More tests => 20; use MARC::Record; use MARC::Field; use DateTime; @@ -47,7 +47,7 @@ $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); my $record = MARC::Record->new(); $record->append_fields( MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), - MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'), + MARC::Field->new('245', ' ', ' ', a => 'Silence in the library', h => 'Book'), MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'), ); my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, $frameworkcode); @@ -330,6 +330,31 @@ C4::Items::ToggleNewStatus( { rules => \@rules } ); $modified_item = Koha::Items->find( $itemnumber ); is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 2, agefield = 'items.datelastseen' : The new_status value is updated|); +# Condition on biblio column +@rules = ( + { + # does not exist + conditions => [ + { + field => 'biblio.medium', + value => 'Book', + }, + ], + substitutions => [ + { + field => 'items.new_status', + value => 'new_updated_value_biblio', + }, + ], + age => '0', + }, +); + +C4::Items::ToggleNewStatus( { rules => \@rules } ); + +$modified_item = Koha::Items->find( $itemnumber ); +is( $modified_item->new_status, 'new_updated_value_biblio', q|ToggleNewStatus: conditions on biblio|); + # Run twice t::lib::Mocks::mock_preference('CataloguingLog', 1); my $actions_nb = $schema->resultset('ActionLog')->count(); -- 2.43.0