Bug 14889: Add tests for Koha::BiblioFramework[s]
[koha.git] / t / db_dependent / Koha / BiblioFrameworks.t
1 #!/usr/bin/perl
2
3 # Copyright 2015 Koha Development team
4 #
5 # This file is part of Koha
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21 use Test::More tests => 3;
22 use Koha::BiblioFramework;
23 use Koha::BiblioFrameworks;
24 use t::lib::TestBuilder;
25
26 my $builder = t::lib::TestBuilder->new;
27 my $nb_of_frameworks = Koha::BiblioFrameworks->search->count;
28 my $new_framework_1 = Koha::BiblioFramework->new({
29     frameworkcode => 'mfw1',
30     frameworktext => 'my_frameworktext_for_fw_1',
31 })->store;
32 my $new_framework_2 = Koha::BiblioFramework->new({
33     frameworkcode => 'mfw2',
34     frameworktext => 'my_frameworktext_for_fw_2',
35 })->store;
36
37 is( Koha::BiblioFrameworks->search->count, $nb_of_frameworks + 2, 'The 2 biblio frameworks should have been added' );
38
39 my $retrieved_framework_1 = Koha::BiblioFrameworks->find( $new_framework_1->frameworkcode );
40 is( $retrieved_framework_1->frameworktext, $new_framework_1->frameworktext, 'Find a biblio framework by frameworkcode should return the correct framework' );
41
42 $retrieved_framework_1->delete;
43 is( Koha::BiblioFrameworks->search->count, $nb_of_frameworks + 1, 'Delete should have deleted the biblio framework' );