Browse Source

Bug 21910: Koha::Library::Groups->get_search_groups should return the groups

To test:
 1 - Add a library group (Admin->Library groups)
 2 - Enable use as an opac and staff search limit
 3 - Add some libraries to the group
 4 - Visit advanced search on staff and opac
 5 - Note the dropdown has as many empty rows as there are libraries
  in the group
 6 - Apply patch, restart all the things
 7 - Visit staff and opac advanced search
 8 - Confirm the group dropdowns are correct
 9 - Enable OpacMastheadLibraryPulldown
10 - Ensure the dropdown on opac shows groups correctly
11 - Confirm earchign groups works from all three locations
12 - prove -v t/db_dependent/LibraryGroups.t

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Nick Clemens 6 years ago
parent
commit
f3b8c66392
  1. 8
      Koha/Library/Groups.pm
  2. 27
      t/db_dependent/LibraryGroups.t

8
Koha/Library/Groups.pm

@ -62,13 +62,9 @@ sub get_search_groups {
my $field = $interface eq 'staff' ? 'ft_search_groups_staff' : 'ft_search_groups_opac';
my @search_groups = $self->search( { $field => 1 } );
my $search_groups = $self->search( { $field => 1 } );
return unless @search_groups;
my @children = map { $_->children() } @search_groups;
return @children;
return wantarray ? $search_groups->as_list : $search_groups;
}
=head3 type

27
t/db_dependent/LibraryGroups.t

@ -4,7 +4,7 @@ use Modern::Perl;
use List::MoreUtils 'any';
use Test::More tests => 19;
use Test::More tests => 20;
use t::lib::TestBuilder;
@ -107,6 +107,31 @@ subtest 'Koha::Library::Group->has_child' => sub {
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' );
};
subtest 'Koha::Library::Group->get_search_groups' => sub {
plan tests => 2;
#Enable as search groups
$groupA->ft_search_groups_opac(1)->store();
$groupB->ft_search_groups_staff(1)->store();
#Update the objects
$groupA = Koha::Library::Groups->find( $groupA->id );
$groupB = Koha::Library::Groups->find( $groupB->id );
my @groups = Koha::Library::Groups->get_search_groups({ interface => 'opac' });
is_deeply( $groups[0]->unblessed, $groupA->unblessed, 'Get search groups opac should return enabled group' );
@groups = Koha::Library::Groups->get_search_groups({ interface => 'staff' });
is_deeply( $groups[0]->unblessed, $groupB->unblessed, 'Get search groups staff should return enabled group' );
# TODO This is not implemented because not used yet
# ->has_child only works with libraries
#is( $groupA->has_child( $groupA1 ), 1, 'groupA1 should be condidered as a child of groupA' );
# FIXME At the time of writing this test fails because the ->children methods does not return more than 1 level of depth
# See Bug 15707 comments 166-170+
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' );
};
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store();
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store();
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store();

Loading…
Cancel
Save