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

(-)a/t/db_dependent/Template/Plugin/Categories.t (-13 / +9 lines)
Lines 1-22 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
use Test::More tests => 5;
3
use Test::More tests => 1;
4
4
5
use C4::Context;
5
use Koha::Database;
6
use Koha::Template::Plugin::Categories;
6
use Koha::Template::Plugin::Categories;
7
use t::lib::TestBuilder;
7
8
8
my $dbh = C4::Context->dbh;
9
my $schema = Koha::Database->new->schema;
9
$dbh->{AutoCommit} = 0;
10
$schema->storage->txn_begin;
10
$dbh->{RaiseError} = 1;
11
12
my $builder = t::lib::TestBuilder->new;
13
$builder->build({ source => 'Category' });
11
14
12
my @categories = Koha::Template::Plugin::Categories->new->all;
15
my @categories = Koha::Template::Plugin::Categories->new->all;
13
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories' );
16
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories' );
14
my $selected_categories = [ grep { $_->{selected} } @categories ];
17
my $selected_categories = [ grep { $_->{selected} } @categories ];
15
is( scalar( @$selected_categories ), 0, 'Plugin Categories should not select one if not given' );
16
18
17
my $category = $categories[-1];
19
$schema->storage->txn_rollback;
18
@categories = Koha::Template::Plugin::Categories->new->all({selected => $category->{categorycode}});
19
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories if selected needed' );
20
$selected_categories = [ grep { $_->{selected} } @categories ];
21
is( scalar( @$selected_categories ), 1, 'Plugin Categories should select only 1 category' );
22
is( $selected_categories->[0]->{categorycode}, $category->{categorycode}, 'Plugin Categories should select the good one' );
23
- 

Return to bug 17640