Bug 17640: Fix t/db_dependent/Template/Plugin/Categories.t
These tests fail since commit 6ee8dd3a59
Bug 15407: Koha::Patron::Categories - replace C4::Category->all
Indeed the patron categories plugin now returns a
Koha::Patron::Categories object and does not set a 'selected' flag.
We do not need this flag (`git grep Categories.all **/*.tt` to trust me)
Note that this patch also add a patron category to make the test passes
even if no category exist.
Test plan:
prove t/db_dependent/Template/Plugin/Categories.t
should return green
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
81cd8b93bb
commit
e7833cf331
|
|
@ -1,22 +1,19 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 1;
|
||||
|
||||
use C4::Context;
|
||||
use Koha::Database;
|
||||
use Koha::Template::Plugin::Categories;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
$builder->build({ source => 'Category' });
|
||||
|
||||
my @categories = Koha::Template::Plugin::Categories->new->all;
|
||||
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories' );
|
||||
my $selected_categories = [ grep { $_->{selected} } @categories ];
|
||||
is( scalar( @$selected_categories ), 0, 'Plugin Categories should not select one if not given' );
|
||||
|
||||
my $category = $categories[-1];
|
||||
@categories = Koha::Template::Plugin::Categories->new->all({selected => $category->{categorycode}});
|
||||
isnt( scalar( @categories ), 0, 'Plugin Categories should return categories if selected needed' );
|
||||
$selected_categories = [ grep { $_->{selected} } @categories ];
|
||||
is( scalar( @$selected_categories ), 1, 'Plugin Categories should select only 1 category' );
|
||||
is( $selected_categories->[0]->{categorycode}, $category->{categorycode}, 'Plugin Categories should select the good one' );
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue