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

(-)a/t/db_dependent/Template/Plugin/Categories.t (-4 / +16 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 6;
20
use Test::More tests => 7;
21
use t::lib::Mocks;
21
use t::lib::Mocks;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
23
Lines 34-47 my $builder = t::lib::TestBuilder->new; Link Here
34
my $nb_categories = Koha::Patron::Categories->count;
34
my $nb_categories = Koha::Patron::Categories->count;
35
35
36
# Create sample categories
36
# Create sample categories
37
my $category_1 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
37
my $category_1 = $builder->build_object( { class => 'Koha::Patron::Categories', value => { description => 'ZZZZZZ' } } );
38
my @categories = Koha::Template::Plugin::Categories->new->all->as_list;
38
my @categories = Koha::Template::Plugin::Categories->new->all->as_list;
39
is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
39
is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
40
40
41
my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
41
my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories', value => { description => 'AAAAAA' } } );
42
@categories = Koha::Template::Plugin::Categories->new->all->as_list;
42
@categories = Koha::Template::Plugin::Categories->new->all->as_list;
43
is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
43
is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
44
44
45
my $category_1_pos = 0;
46
my $category_2_pos = 0;
47
for ( my $i = 0 ; $i < scalar(@categories) ; $i++ ) {
48
    my $idescription = $categories[$i]->description // '';
49
    if ( $idescription eq $category_1->description ) {
50
        $category_1_pos = $i;
51
    }
52
    if ( $idescription eq $category_2->description ) {
53
        $category_2_pos = $i;
54
    }
55
}
56
ok( $category_1_pos > $category_2_pos, 'Categories are sorted by description' );
57
45
is( Koha::Template::Plugin::Categories->GetName(
58
is( Koha::Template::Plugin::Categories->GetName(
46
        $category_1->categorycode
59
        $category_1->categorycode
47
    ),
60
    ),
48
- 

Return to bug 32127