Bug 32127: Add unit test
Run prove t/db_dependent/Template/Plugin/Categories.t
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit c101afb0a0
)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
79e0674da6
commit
acac225161
1 changed files with 16 additions and 3 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 6;
|
||||
use Test::More tests => 7;
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
|
@ -34,14 +34,27 @@ my $builder = t::lib::TestBuilder->new;
|
|||
my $nb_categories = Koha::Patron::Categories->count;
|
||||
|
||||
# Create sample categories
|
||||
my $category_1 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
|
||||
my $category_1 = $builder->build_object( { class => 'Koha::Patron::Categories', value => { description => 'ZZZZZZ' } } );
|
||||
my @categories = Koha::Template::Plugin::Categories->new->all->as_list;
|
||||
is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
|
||||
|
||||
my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
|
||||
my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories', value => { description => 'AAAAAA' } } );
|
||||
@categories = Koha::Template::Plugin::Categories->new->all->as_list;
|
||||
is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
|
||||
|
||||
my $category_1_pos = 0;
|
||||
my $category_2_pos = 0;
|
||||
for ( my $i = 0 ; $i < scalar(@categories) ; $i++ ) {
|
||||
my $idescription = $categories[$i]->description // '';
|
||||
if ( $idescription eq $category_1->description ) {
|
||||
$category_1_pos = $i;
|
||||
}
|
||||
if ( $idescription eq $category_2->description ) {
|
||||
$category_2_pos = $i;
|
||||
}
|
||||
}
|
||||
ok( $category_1_pos > $category_2_pos, 'Categories are sorted by description' );
|
||||
|
||||
is( Koha::Template::Plugin::Categories->GetName(
|
||||
$category_1->categorycode
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue