|
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 => 16; |
7 |
use Test::More tests => 17; |
| 8 |
|
8 |
|
| 9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
| 10 |
|
10 |
|
|
Lines 84-89
subtest 'Koha::Library->library_groups' => sub {
Link Here
|
| 84 |
is( $groups->count, 2, 'Library 1 should be part of 2 groups' ); |
84 |
is( $groups->count, 2, 'Library 1 should be part of 2 groups' ); |
| 85 |
}; |
85 |
}; |
| 86 |
|
86 |
|
|
|
87 |
# root_group |
| 88 |
# + groupA |
| 89 |
# + groupA1 |
| 90 |
# + groupA1_library2 |
| 91 |
# + groupA_library1 |
| 92 |
# + groupA2 |
| 93 |
# + groupB |
| 94 |
# + groupB_library1 |
| 95 |
|
| 96 |
subtest 'Koha::Library::Group->has_child' => sub { |
| 97 |
plan tests => 2; |
| 98 |
is( $groupA->has_child( $library1->{branchcode} ), 1, 'library1 should be condidered as a child of groupA' ); |
| 99 |
is( $groupB->has_child( $library2->{branchcode} ), 0, 'library2 should not be considered as a child of groupB' ); |
| 100 |
|
| 101 |
# TODO This is not implemented because not used yet |
| 102 |
# ->has_child only works with libraries |
| 103 |
#is( $groupA->has_child( $groupA1 ), 1, 'groupA1 should be condidered as a child of groupA' ); |
| 104 |
|
| 105 |
# FIXME At the time of writing this test fails because the ->children methods does not return more than 1 level of depth |
| 106 |
# See Bug 15707 comments 166-170+ |
| 107 |
#is( $groupA->has_child( $groupA1_library2->branchcode ), 1, 'groupA1_library2 should be considered as a child of groupA (it is a grandchild)' ); |
| 108 |
}; |
| 109 |
|
| 87 |
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); |
110 |
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); |
| 88 |
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); |
111 |
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); |
| 89 |
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); |
112 |
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); |
| 90 |
- |
|
|