From 34aea719282169dc1862f9a4699be6d26d4067d4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 15 Jun 2022 12:08:05 +0000 Subject: [PATCH] Bug 29454: (follow-up) Cover more test cases Signed-off-by: Martin Renvoize --- .../Koha/Template/Plugin/ItemTypes.t | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Template/Plugin/ItemTypes.t b/t/db_dependent/Koha/Template/Plugin/ItemTypes.t index 4f99bcbdca..59726397e5 100755 --- a/t/db_dependent/Koha/Template/Plugin/ItemTypes.t +++ b/t/db_dependent/Koha/Template/Plugin/ItemTypes.t @@ -16,7 +16,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 10; use C4::Context; use Koha::Database; @@ -77,6 +77,15 @@ Koha::Localization->new( translation => 'Translated itemtype B' } )->store; +my $itemtypeC = $builder->build_object( + { + class => 'Koha::ItemTypes', + value => { + parent_type => undef, + description => "Desc itemtype C", + } + } +); my $GetDescriptionA1 = $plugin->GetDescription($itemtypeA->itemtype); is($GetDescriptionA1, "Translated itemtype A", "ItemType without parent - GetDescription without want parent"); @@ -88,6 +97,18 @@ is($GetDescriptionB1, "Translated itemtype B", "ItemType with parent - GetDescri my $GetDescriptionB2 = $plugin->GetDescription($itemtypeB->itemtype, 1); is($GetDescriptionB2, "Translated itemtype A->Translated itemtype B", "ItemType with parent - GetDescription with want parent"); +my $GetDescriptionC1 = $plugin->GetDescription($itemtypeC->itemtype); +is($GetDescriptionC1, "Desc itemtype C", "ItemType without parent - GetDescription without want parent - No translation"); + +$itemtypeC->description("New desc itemtype C")->store(); + +# For normal (web) requests cache is flushed - pretend we did here +my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); +$memory_cache->flush; + +$GetDescriptionC1 = $plugin->GetDescription($itemtypeC->itemtype); +is($GetDescriptionC1, "New desc itemtype C", "ItemType without parent - GetDescription without want parent - No translation - updated value returned"); + $schema->storage->txn_rollback; 1; -- 2.20.1