Bug 24201: fix failing tests
[koha.git] / t / Koha / Plugins / Tab.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Test::More tests => 1;
21 use Test::Exception;
22
23 use Koha::Plugins::Tab;
24
25 subtest 'new() tests' => sub {
26     plan tests => 7;
27
28     throws_ok { Koha::Plugins::Tab->new( { title => 'A title' } ); }
29     'Koha::Exceptions::MissingParameter',
30       'Exception is thrown on missing content';
31
32     is(
33         "$@",
34         "Mandatory parameter 'content' missing",
35         'Exception message is correct'
36     );
37
38     throws_ok { Koha::Plugins::Tab->new( { content => 'Some content' } ); }
39     'Koha::Exceptions::MissingParameter',
40       'Exception is thrown on missing title';
41
42     is(
43         "$@",
44         "Mandatory parameter 'title' missing",
45         'Exception message is correct'
46     );
47
48     my $tab = Koha::Plugins::Tab->new(
49         {
50             title   => 'A title',
51             content => 'Some content'
52         }
53     );
54
55     is( $tab->title, 'A title', 'title accessor is correct' );
56     is( $tab->content, 'Some content', 'content accessor is correct' );
57
58     my $id = 'calculated-id';
59     $tab->id($id);
60
61     is( $tab->id, $id, 'The id can be calculated and set on runtime' );
62 };