Bug 18292: Remove return 1 statements in tests
[koha.git] / t / db_dependent / Template / Plugin / Categories.t
blob6ea75f8d5f8f288b43bfa1f17c4b4801b4789bed
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use Test::More tests => 4;
21 use t::lib::TestBuilder;
23 use Koha::Patron::Categories;
24 use Koha::Checkouts;
25 use Koha::Patrons;
26 use Koha::Database;
27 use Koha::Template::Plugin::Categories;
29 my $schema = Koha::Database->new->schema;
30 $schema->storage->txn_begin;
32 # Delete all categories
33 Koha::Checkouts->search->delete;
34 Koha::Patrons->search->delete;
35 Koha::Patron::Categories->search->delete;
37 my $builder = t::lib::TestBuilder->new;
39 is( Koha::Template::Plugin::Categories->new->all->count,
40 0, '->all returns 0 results if no categories defined' );
42 # Create sample categories
43 my $category_1 = $builder->build( { source => 'Category' } );
44 my @categories = Koha::Template::Plugin::Categories->new->all;
45 is( scalar(@categories), 1, '->all returns all defined categories' );
47 my $category_2 = $builder->build( { source => 'Category' } );
48 @categories = Koha::Template::Plugin::Categories->new->all;
49 is( scalar(@categories), 2, '->all returns all defined categories' );
51 is( Koha::Template::Plugin::Categories->GetName(
52 $category_1->{categorycode}
54 $category_1->{description},
55 '->GetName returns the right description'
58 $schema->storage->txn_rollback;