View | Details | Raw Unified | Return to bug 17640
Collapse All | Expand All

(-)a/t/db_dependent/Template/Plugin/Categories.t (-5 / +41 lines)
Lines 1-6 Link Here
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
1
use Modern::Perl;
18
use Modern::Perl;
2
19
3
use Test::More tests => 1;
20
use Test::More tests => 4;
4
21
5
use Koha::Database;
22
use Koha::Database;
6
use Koha::Template::Plugin::Categories;
23
use Koha::Template::Plugin::Categories;
Lines 9-19 use t::lib::TestBuilder; Link Here
9
my $schema = Koha::Database->new->schema;
26
my $schema = Koha::Database->new->schema;
10
$schema->storage->txn_begin;
27
$schema->storage->txn_begin;
11
28
29
# Delete all categories
30
$schema->resultset('Borrower')->search->delete;
31
$schema->resultset('Category')->search->delete;
32
12
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
13
$builder->build({ source => 'Category' });
14
34
35
is( Koha::Template::Plugin::Categories->new->all->count,
36
    0, '->all returns 0 results if no categories defined' );
37
38
# Create sample categories
39
my $category_1 = $builder->build( { source => 'Category' } );
15
my @categories = Koha::Template::Plugin::Categories->new->all;
40
my @categories = Koha::Template::Plugin::Categories->new->all;
16
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories' );
41
is( scalar(@categories), 1, '->all returns all defined categories' );
17
my $selected_categories = [ grep { $_->{selected} } @categories ];
42
43
my $category_2 = $builder->build( { source => 'Category' } );
44
@categories = Koha::Template::Plugin::Categories->new->all;
45
is( scalar(@categories), 2, '->all returns all defined categories' );
46
47
is( Koha::Template::Plugin::Categories->GetName(
48
        $category_1->{categorycode}
49
    ),
50
    $category_1->{description},
51
    '->GetName returns the right description'
52
);
18
53
19
$schema->storage->txn_rollback;
54
$schema->storage->txn_rollback;
20
- 
55
56
1;

Return to bug 17640