From ac041571c3da103b1469065c1fd5c1b9c529c04c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 17 Nov 2022 10:15:30 +0000 Subject: [PATCH] Bug 24606: (QA follow-up) Add test for encoding/decoding NOTE: I have the impression that this unit test is quite rudimentary. I do not see the apply function tested? Test plan: Run t/db_dependent/Koha/Item/Templates.t Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi tcohen amended: stray deps Signed-off-by: Tomas Cohen Arazi --- Koha/Item/Template.pm | 3 +-- t/db_dependent/Koha/Item/Templates.t | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Koha/Item/Template.pm b/Koha/Item/Template.pm index 8adf9ea125..3c0e40f9ce 100644 --- a/Koha/Item/Template.pm +++ b/Koha/Item/Template.pm @@ -17,8 +17,7 @@ package Koha::Item::Template; use Modern::Perl; -use Encode qw(encode_utf8); -use JSON qw(encode_json decode_json); +use JSON; use base qw(Koha::Object); diff --git a/t/db_dependent/Koha/Item/Templates.t b/t/db_dependent/Koha/Item/Templates.t index 1a7bc25556..dca1e66511 100755 --- a/t/db_dependent/Koha/Item/Templates.t +++ b/t/db_dependent/Koha/Item/Templates.t @@ -18,6 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; +use utf8; use Koha::Database; @@ -31,7 +32,7 @@ my $builder = t::lib::TestBuilder->new; use_ok("Koha::Item::Templates"); subtest 'get_available' => sub { - plan tests => 2; + plan tests => 3; $schema->storage->txn_begin; @@ -78,10 +79,12 @@ subtest 'get_available' => sub { { patron_id => $patron_2->id, name => 'My template', - contents => { location => 'test' }, + contents => { location => 'test🙂' }, is_shared => 0, } - )->store(); + )->store; + $unshared_template->discard_changes; # refresh + is( $unshared_template->decoded_contents->{location}, 'test🙂', 'Tested encoding/decoding' ); my $templates = Koha::Item::Templates->get_available( $patron_1->id ); is( $templates->{owned}->count, 1, "Got back one owned template" ); -- 2.39.5