From bc59661f1457b7eed0e18c4c18b29d4dc9876e62 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 25 Apr 2024 16:58:34 +0100 Subject: [PATCH] Bug 32435: Unit tests for Ticket/Ticket::Update change We add a fallback to allow TICKET_RESOLUTIONS to be returned in the strings_map as additional TICKET_STATUS states. Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- t/db_dependent/Koha/Ticket.t | 33 ++++++++++++++++++++++++++++- t/db_dependent/Koha/Ticket/Update.t | 33 ++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Ticket.t b/t/db_dependent/Koha/Ticket.t index 51c862ff77..7734f6de67 100755 --- a/t/db_dependent/Koha/Ticket.t +++ b/t/db_dependent/Koha/Ticket.t @@ -229,7 +229,7 @@ subtest 'store() tests' => sub { }; subtest 'strings_map() tests' => sub { - plan tests => 8; + plan tests => 16; $schema->storage->txn_begin; @@ -264,5 +264,36 @@ subtest 'strings_map() tests' => sub { is( $strings->{status}->{type}, 'av', "'type' is 'av'" ); is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" ); + my $resolution_av = $builder->build_object( + { + class => 'Koha::AuthorisedValues', + value => { + authorised_value => 'RES_TEST', + category => 'TICKET_RESOLUTION', + lib => 'internal resolution description', + lib_opac => 'public resolution description', + } + } + ); + + $ticket = $builder->build_object( + { + class => 'Koha::Tickets', + value => { status => 'RES_TEST' } + } + ); + + $strings = $ticket->strings_map(); + ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough" ); + is( $strings->{status}->{str}, $resolution_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->strings_map( { public => 1 } ); + ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough when called in public" ); + is( $strings->{status}->{str}, $resolution_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; }; diff --git a/t/db_dependent/Koha/Ticket/Update.t b/t/db_dependent/Koha/Ticket/Update.t index 5b3fc8bc82..ebd1b4997d 100755 --- a/t/db_dependent/Koha/Ticket/Update.t +++ b/t/db_dependent/Koha/Ticket/Update.t @@ -74,7 +74,7 @@ subtest 'user() tests' => sub { }; subtest 'strings_map() tests' => sub { - plan tests => 8; + plan tests => 16; $schema->storage->txn_begin; @@ -109,5 +109,36 @@ subtest 'strings_map() tests' => sub { is( $strings->{status}->{type}, 'av', "'type' is 'av'" ); is( $strings->{status}->{category}, 'TICKET_STATUS', "'category' exists and set to 'TICKET_STATUS'" ); + my $resolution_av = $builder->build_object( + { + class => 'Koha::AuthorisedValues', + value => { + authorised_value => 'RES_TEST', + category => 'TICKET_RESOLUTION', + lib => 'internal resolution description', + lib_opac => 'public resolution description', + } + } + ); + + $ticket_update = $builder->build_object( + { + class => 'Koha::Ticket::Updates', + value => { status => 'RES_TEST' } + } + ); + + $strings = $ticket_update->strings_map(); + ok( exists $strings->{status}, "'status' entry exists for resolution fallthrough" ); + is( $strings->{status}->{str}, $resolution_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 for resolution fallthrough when called in public" ); + is( $strings->{status}->{str}, $resolution_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.39.5