3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Test::More tests => 6;
25 use t::lib::TestBuilder;
29 use_ok('Koha::Template::Plugin::Notices');
32 my $schema = Koha::Database->schema;
33 my $builder = t::lib::TestBuilder->new;
35 $schema->storage->txn_begin;
37 my $plugin = Koha::Template::Plugin::Notices->new();
38 ok( $plugin, "initialized Notices plugin" );
40 my $notice_templates = Koha::Notice::Templates->search();
42 my $fetched_templates = $plugin->GetTemplates(undef);
43 is( scalar @$fetched_templates, $notice_templates->count, "All templates returned when no parameters passed" );
45 my $notice_A = $builder->build_object(
47 class => 'Koha::Notice::Templates',
52 $fetched_templates = $plugin->GetTemplates( $notice_A->module );
53 is( scalar @$fetched_templates, 1, "GetTemplates with module passed gets the one notice in new module" );
55 is_deeply( @$fetched_templates[0]->unblessed, $notice_A->unblessed, 'The notice is correctly retrieved' );
59 $fetched_templates = $plugin->GetTemplates( $notice_A->module );
60 is( scalar @$fetched_templates, 0, "No notice returned when invalid module passed" );
62 $schema->storage->txn_rollback;