|
Lines 4-10
use Modern::Perl;
Link Here
|
| 4 |
|
4 |
|
| 5 |
use List::MoreUtils 'any'; |
5 |
use List::MoreUtils 'any'; |
| 6 |
|
6 |
|
| 7 |
use Test::More tests => 19; |
7 |
use Test::More tests => 20; |
| 8 |
|
8 |
|
| 9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
| 10 |
|
10 |
|
|
Lines 107-112
subtest 'Koha::Library::Group->has_child' => sub {
Link Here
|
| 107 |
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' ); |
107 |
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' ); |
| 108 |
}; |
108 |
}; |
| 109 |
|
109 |
|
|
|
110 |
subtest 'Koha::Library::Group->get_search_groups' => sub { |
| 111 |
plan tests => 2; |
| 112 |
|
| 113 |
#Enable as search groups |
| 114 |
$groupA->ft_search_groups_opac(1)->store(); |
| 115 |
$groupB->ft_search_groups_staff(1)->store(); |
| 116 |
|
| 117 |
#Update the objects |
| 118 |
$groupA = Koha::Library::Groups->find( $groupA->id ); |
| 119 |
$groupB = Koha::Library::Groups->find( $groupB->id ); |
| 120 |
|
| 121 |
my @groups = Koha::Library::Groups->get_search_groups({ interface => 'opac' }); |
| 122 |
is_deeply( $groups[0]->unblessed, $groupA->unblessed, 'Get search groups opac should return enabled group' ); |
| 123 |
@groups = Koha::Library::Groups->get_search_groups({ interface => 'staff' }); |
| 124 |
is_deeply( $groups[0]->unblessed, $groupB->unblessed, 'Get search groups staff should return enabled group' ); |
| 125 |
|
| 126 |
# TODO This is not implemented because not used yet |
| 127 |
# ->has_child only works with libraries |
| 128 |
#is( $groupA->has_child( $groupA1 ), 1, 'groupA1 should be condidered as a child of groupA' ); |
| 129 |
|
| 130 |
# FIXME At the time of writing this test fails because the ->children methods does not return more than 1 level of depth |
| 131 |
# See Bug 15707 comments 166-170+ |
| 132 |
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' ); |
| 133 |
}; |
| 134 |
|
| 110 |
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); |
135 |
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); |
| 111 |
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); |
136 |
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); |
| 112 |
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); |
137 |
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); |
| 113 |
- |
|
|