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 => 13; |
7 |
use Test::More tests => 14; |
8 |
|
8 |
|
9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
10 |
|
10 |
|
Lines 51-58
ok( $in_list, 'New root group is in the list returned by the get_root_groups met
Link Here
|
51 |
my $groupA = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group A' })->store(); |
51 |
my $groupA = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group A' })->store(); |
52 |
my $groupA1 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A1' })->store(); |
52 |
my $groupA1 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A1' })->store(); |
53 |
my $groupA2 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A2' })->store(); |
53 |
my $groupA2 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A2' })->store(); |
|
|
54 |
my $groupB = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group B' })->store(); |
54 |
|
55 |
|
55 |
my $groupA_library1 = Koha::Library::Group->new({ parent_id => $groupA->id, branchcode => $library1->{branchcode} })->store(); |
56 |
my $groupA_library1 = Koha::Library::Group->new({ parent_id => $groupA->id, branchcode => $library1->{branchcode} })->store(); |
|
|
57 |
my $groupB_library1 = Koha::Library::Group->new({ parent_id => $groupB->id, branchcode => $library1->{branchcode} })->store(); |
56 |
my $groupA1_library2 = Koha::Library::Group->new({ parent_id => $groupA1->id, branchcode => $library2->{branchcode} })->store(); |
58 |
my $groupA1_library2 = Koha::Library::Group->new({ parent_id => $groupA1->id, branchcode => $library2->{branchcode} })->store(); |
57 |
|
59 |
|
58 |
my @children = $root_group->children()->as_list(); |
60 |
my @children = $root_group->children()->as_list(); |
Lines 77-79
$in_list = any { $_->id eq $groupA_library1->branchcode } @libraries_not_direct_
Link Here
|
77 |
ok( !$in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 1 is not in the list'); |
79 |
ok( !$in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 1 is not in the list'); |
78 |
$in_list = any { $_->id eq $groupA1_library2->branchcode } @libraries_not_direct_children; |
80 |
$in_list = any { $_->id eq $groupA1_library2->branchcode } @libraries_not_direct_children; |
79 |
ok( $in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 2 is in the list'); |
81 |
ok( $in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 2 is in the list'); |
80 |
- |
82 |
|
|
|
83 |
subtest 'Koha::Library->library_groups' => sub { |
84 |
plan tests => 4; |
85 |
my $library3 = Koha::Libraries->find( $library3->{branchcode} ); |
86 |
my $groups = $library3->library_groups; |
87 |
is( ref( $groups ), 'Koha::Library::Groups', 'Koha::Library->library_groups should return Koha::Library::Groups' ); |
88 |
is( $groups->count, 0, 'Library 3 should not be part of any groups'); |
89 |
|
90 |
my $library1 = Koha::Libraries->find( $library1->{branchcode} ); |
91 |
$groups = $library1->library_groups; |
92 |
is( ref( $groups ), 'Koha::Library::Groups', 'Koha::Library->library_groups should return Koha::Library::Groups' ); |
93 |
is( $groups->count, 2, 'Library 1 should be part of 2 groups' ); |
94 |
}; |