From 16377239d999916adf1a59cb65a60b9fdf27cd6a Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Thu, 25 Apr 2024 16:51:09 +0100
Subject: [PATCH] Bug 35628: Add unit tests for Koha::Ticket::Update addition

We add a strings_map method to Koha::Ticket::Update and thus need
to have corresponding unit tests.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 t/db_dependent/Koha/Ticket/Update.t | 41 ++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/Koha/Ticket/Update.t b/t/db_dependent/Koha/Ticket/Update.t
index 8c357aef783..5b3fc8bc828 100755
--- a/t/db_dependent/Koha/Ticket/Update.t
+++ b/t/db_dependent/Koha/Ticket/Update.t
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 2;
+use Test::More tests => 3;
 use t::lib::TestBuilder;
 
 use Koha::Database;
@@ -72,3 +72,42 @@ subtest 'user() tests' => sub {
 
     $schema->storage->txn_rollback;
 };
+
+subtest 'strings_map() tests' => sub {
+    plan tests => 8;
+
+    $schema->storage->txn_begin;
+
+    my $status_av = $builder->build_object(
+        {
+            class => 'Koha::AuthorisedValues',
+            value => {
+                authorised_value => 'TEST',
+                category         => 'TICKET_STATUS',
+                lib              => 'internal description',
+                lib_opac         => 'public description',
+            }
+        }
+    );
+
+    my $ticket_update = $builder->build_object(
+        {
+            class => 'Koha::Ticket::Updates',
+            value => { status => 'TEST' }
+        }
+    );
+
+    my $strings = $ticket_update->strings_map();
+    ok( exists $strings->{status}, "'status' entry exists" );
+    is( $strings->{status}->{str},      $status_av->lib, "'str' set to av->lib" );
+    is( $strings->{status}->{type},     'av',            "'type' is 'av'" );
+    is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" );
+
+    $strings = $ticket_update->strings_map( { public => 1 } );
+    ok( exists $strings->{status}, "'status' entry exists when called in public" );
+    is( $strings->{status}->{str},      $status_av->lib_opac, "'str' set to av->lib_opac when called in public" );
+    is( $strings->{status}->{type},     'av',                 "'type' is 'av'" );
+    is( $strings->{status}->{category}, 'TICKET_STATUS',      "'category' exists and set to 'TICKET_STATUS'" );
+
+    $schema->storage->txn_rollback;
+};
-- 
2.44.0