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

(-)a/t/db_dependent/Template/Plugin/Branches.t (+35 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
use Test::More tests => 5;
4
5
use C4::Context;
6
use C4::Branch;
7
use Koha::Template::Plugin::Branches;
8
9
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
13
for my $i ( 1 .. 5 ) {
14
    C4::Branch::ModBranch(
15
{
16
        branchcode     => "test_br_$i",
17
        branchname     => "test_br_$i",
18
        add => 1,
19
}
20
    );
21
22
}
23
24
my $branches = Koha::Template::Plugin::Branches->new->all;
25
my $test_branches = [ grep { $_->{branchcode} =~ m|^test_br_| } @$branches ];
26
is( scalar( @$test_branches ), 5, 'Plugin Branches should return the branches' );
27
my $selected_branches = [ grep { $_->{selected} } @$branches ];
28
is( scalar( @$selected_branches ), 0, 'Plugin Branches should not select a branch if not needed' );
29
30
$branches = Koha::Template::Plugin::Branches->new->all({selected => 'test_br_3'});
31
$test_branches = [ grep { $_->{branchcode} =~ m|^test_br_| } @$branches ];
32
is( scalar( @$test_branches ), 5, 'Plugin Branches should return the branches if selected passed' );
33
$selected_branches = [ grep { $_->{selected} } @$branches ];
34
is( scalar( @$selected_branches ), 1, 'Plugin Branches should return only 1 selected if passed' );
35
is( $selected_branches->[0]->{branchcode}, 'test_br_3', 'Plugin Branches should select the good one' );
(-)a/t/db_dependent/Template/Plugin/Categories.t (-1 / +23 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
use Test::More tests => 5;
4
5
use C4::Context;
6
use C4::Branch;
7
use Koha::Template::Plugin::Categories;
8
9
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
13
my @categories = Koha::Template::Plugin::Categories->new->all;
14
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories' );
15
my $selected_categories = [ grep { $_->{selected} } @categories ];
16
is( scalar( @$selected_categories ), 0, 'Plugin Categories should not select one if not given' );
17
18
my $category = $categories[-1];
19
@categories = Koha::Template::Plugin::Categories->new->all({selected => $category->{categorycode}});
20
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories if selected needed' );
21
$selected_categories = [ grep { $_->{selected} } @categories ];
22
is( scalar( @$selected_categories ), 1, 'Plugin Categories should select only 1 category' );
23
is( $selected_categories->[0]->{categorycode}, $category->{categorycode}, 'Plugin Categories should select the good one' );

Return to bug 7380