From 94620cabbee51e215209ea5c3e2cb77e99668825 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Mon, 24 Jul 2023 14:00:48 +0000
Subject: [PATCH] Bug 34357: Replace SUPER->imageurl in ItemTypes

Test plan:
Run t/db_dependent/Koha/ItemTypes.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 Koha/ItemType.pm                |  2 +-
 t/db_dependent/Koha/ItemTypes.t | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm
index dbbae3fbfc..18f2544604 100644
--- a/Koha/ItemType.pm
+++ b/Koha/ItemType.pm
@@ -86,7 +86,7 @@ sub delete {
 
 sub image_location {
     my ( $self, $interface ) = @_;
-    return C4::Koha::getitemtypeimagelocation( $interface, $self->SUPER::imageurl );
+    return C4::Koha::getitemtypeimagelocation( $interface, $self->imageurl );
 }
 
 =head3 translated_description
diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t
index aecd8d971b..d62cf05e48 100755
--- a/t/db_dependent/Koha/ItemTypes.t
+++ b/t/db_dependent/Koha/ItemTypes.t
@@ -19,8 +19,7 @@
 
 use Modern::Perl;
 
-use Data::Dumper;
-use Test::More tests => 14;
+use Test::More tests => 15;
 
 use t::lib::Mocks;
 use t::lib::TestBuilder;
@@ -134,4 +133,21 @@ $biblio->delete;
 
 is ( $item_type->can_be_deleted, 1, 'The item type that was being used by the removed item and biblioitem can now be deleted' );
 
+subtest 'image_location' => sub {
+    plan tests => 3;
+
+    my $item_type = $builder->build_object( { class => 'Koha::ItemTypes' } );
+    $item_type->imageurl('https://myserver.org/image01');
+    is( $item_type->image_location, 'https://myserver.org/image01', 'Check URL' );
+    $item_type->imageurl('bridge/newthing.png');
+    is(
+        $item_type->image_location('opac'), '/opac-tmpl/bootstrap/itemtypeimg/bridge/newthing.png',
+        'Check path for opac'
+    );
+    is(
+        $item_type->image_location('intranet'), '/intranet-tmpl/prog/img/itemtypeimg/bridge/newthing.png',
+        'Check path for intranet'
+    );
+};
+
 $schema->txn_rollback;
-- 
2.30.2