Koha/t/db_dependent/Template/Plugin/NoticeTemplates.t
Martin Renvoize 5f4caff701
Bug 29393: (QA follow-up) Tidy and make executable the new test
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 17:38:01 +02:00

77 lines
1.9 KiB
Perl
Executable file

#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 4;
use Koha::Database;
use Koha::Notice::Templates;
use t::lib::TestBuilder;
BEGIN {
use_ok('Koha::Template::Plugin::NoticeTemplates');
}
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
$schema->storage->txn_begin;
Koha::Notice::Templates->delete();
my $notice_templates = Koha::Notice::Templates->search( { module => 'members' } );
$builder->build(
{
source => 'Letter',
value => {
name => 'Hold cancellation',
module => 'reserves'
}
}
);
$builder->build(
{
source => 'Letter',
value => {
name => 'Account expiration',
module => 'members'
}
}
);
$builder->build(
{
source => 'Letter',
value => {
name => 'Discharge',
module => 'members'
}
}
);
my $plugin = Koha::Template::Plugin::NoticeTemplates->new();
ok( $plugin, "initialized notice templates plugin" );
my $notices = $plugin->GetByModule('members');
is( $notices->count, 2, 'returns 2 defined members letters' );
$notices = $plugin->GetByModule('reserves');
is( $notices->count, 1, 'returns 2 defined reserves letters' );
$schema->storage->txn_rollback;