Revert Bug 31421
authorArthur Suzuki <arthur.suzuki@biblibre.com>
Mon, 21 Nov 2022 09:56:22 +0000 (10:56 +0100)
committerArthur Suzuki <arthur.suzuki@biblibre.com>
Mon, 21 Nov 2022 09:56:22 +0000 (10:56 +0100)
Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Koha/Template/Plugin/Categories.pm
koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc
t/db_dependent/Template/Plugin/Categories.t

index 4da8748..db7b2fd 100644 (file)
@@ -25,11 +25,6 @@ use Koha::Patron::Categories;
 
 sub all {
     my ( $self, $params ) = @_;
-    return Koha::Patron::Categories->search($params);
-}
-
-sub limited {
-    my ( $self, $params ) = @_;
     return Koha::Patron::Categories->search_with_library_limits($params);
 }
 
@@ -61,14 +56,9 @@ Koha::Template::Plugin::Categories - TT Plugin for categories
 
 =head2 all
 
-In a template, you can get all the categories with
+In a template, you can get the all categories with
 the following TT code: [% Categories.all() %]
 
-=head2 limited
-
-In a template, you can get the categories with library limits applied with
-the following TT code: [% Categories.limited() %]
-
 =head2 GetName
 
 In a template, you can get the name of a patron category using
index e26c5e6..4626a40 100644 (file)
@@ -1,7 +1,7 @@
 [% INCLUDE 'blocking_errors.inc' %]
 [% USE Categories %]
 [% USE Koha %]
-[% SET categories = Categories.limited %]
+[% SET categories = Categories.all %]
 
 [% UNLESS ( no_add ) %]
 <div id="toolbar" class="btn-toolbar">
index c409ccf..0d99a85 100755 (executable)
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 6;
+use Test::More tests => 4;
 use t::lib::Mocks;
 use t::lib::TestBuilder;
 
@@ -31,35 +31,25 @@ my $schema = Koha::Database->new->schema;
 $schema->storage->txn_begin;
 
 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 @categories = Koha::Template::Plugin::Categories->new->all->as_list;
+my $category_1 = $builder->build( { source => 'Category' } );
+my @categories = Koha::Template::Plugin::Categories->new->all;
 is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' );
 
-my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories' } );
-@categories = Koha::Template::Plugin::Categories->new->all->as_list;
+my $category_2 = $builder->build( { source => 'Category' } );
+@categories = Koha::Template::Plugin::Categories->new->all;
 is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' );
 
 is( Koha::Template::Plugin::Categories->GetName(
-        $category_1->categorycode
+        $category_1->{categorycode}
     ),
-    $category_1->description,
+    $category_1->{description},
     '->GetName returns the right description'
 );
 
-my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } );
-my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } );
-$category_1->library_limits( [ $library_1->branchcode ] );
-$category_2->library_limits( [ $library_2->branchcode ] );
-t::lib::Mocks::mock_userenv( { branchcode => $library_1->branchcode } );
-my $limited = Koha::Template::Plugin::Categories->limited;
-is( $limited->search( { 'me.categorycode' => $category_1->categorycode } )->count,
-    1, 'Category 1 is available from library 1' );
-is( $limited->search( { 'me.categorycode' => $category_2->categorycode } )->count,
-    0, 'Category 2 is not available from library 1' );
-
 $schema->storage->txn_rollback;
 
 subtest 'can_any_reset_password() tests' => sub {