From 351c81544cb41a91ccc076f96813d6ca01957680 Mon Sep 17 00:00:00 2001 From: Sam Lau Date: Mon, 24 Jun 2024 19:54:02 +0000 Subject: [PATCH] Bug 27182: Unit tests To test: prove t/db_dependent/MarcModificationTemplates.t --- t/db_dependent/MarcModificationTemplates.t | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/MarcModificationTemplates.t b/t/db_dependent/MarcModificationTemplates.t index 35adf6919d..67e5dda2d5 100755 --- a/t/db_dependent/MarcModificationTemplates.t +++ b/t/db_dependent/MarcModificationTemplates.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 129; +use Test::More tests => 130; use Koha::Database; use Koha::SimpleMARC; @@ -11,7 +11,7 @@ use t::lib::Mocks; use_ok("MARC::Field"); use_ok("MARC::Record"); -use_ok('C4::MarcModificationTemplates', qw( AddModificationTemplate AddModificationTemplateAction GetModificationTemplateAction GetModificationTemplateActions ModModificationTemplateAction MoveModificationTemplateAction DelModificationTemplate DelModificationTemplateAction ModifyRecordWithTemplate GetModificationTemplates )); +use_ok('C4::MarcModificationTemplates', qw( AddModificationTemplate AddModificationTemplateAction GetModificationTemplateAction GetModificationTemplateActions ModModificationTemplateAction MoveModificationTemplateAction DelModificationTemplate DelModificationTemplateAction ModifyRecordWithTemplate GetModificationTemplates RenameModificationTemplate)); my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -386,6 +386,17 @@ subtest 'GetModificationTemplates' => sub { is_deeply( [map{$_->{name}} @templates], ['aaa', 'mmm', 'zzz'] ); }; +subtest 'RenameModificationTemplate' => sub { + plan tests => 1; + $dbh->do(q|DELETE FROM marc_modification_templates|); + my $template_id = AddModificationTemplate("koah"); + my $template_id2 = AddModificationTemplate("sma"); + RenameModificationTemplate("koha", $template_id); + RenameModificationTemplate("sam", $template_id2); + my @templates = GetModificationTemplates(); + is_deeply( [map{$_->{name}} @templates], ['koha', 'sam'] ); +}; + subtest "not_equals" => sub { plan tests => 2; $dbh->do(q|DELETE FROM marc_modification_templates|); -- 2.39.2