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 => 20; |
7 |
use Test::More tests => 21; |
8 |
|
8 |
|
9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
10 |
use Koha::Database; |
10 |
use Koha::Database; |
Lines 144-146
is( ref($groupX->libraries), 'Koha::Libraries', '->libraries should return a Koh
Link Here
|
144 |
@group_branchcodes = sort( map { $_->branchcode } $groupX->all_libraries ); |
144 |
@group_branchcodes = sort( map { $_->branchcode } $groupX->all_libraries ); |
145 |
is_deeply( \@branchcodes, \@group_branchcodes, "Group all_libraries are returned correctly" ); |
145 |
is_deeply( \@branchcodes, \@group_branchcodes, "Group all_libraries are returned correctly" ); |
146 |
is( ref(($groupX->all_libraries)[0]), 'Koha::Library', '->all_libraries should return a list of Koha::Library - in the future it should be fixed to return a Koha::Libraries iterator instead'); # FIXME |
146 |
is( ref(($groupX->all_libraries)[0]), 'Koha::Library', '->all_libraries should return a list of Koha::Library - in the future it should be fixed to return a Koha::Libraries iterator instead'); # FIXME |
147 |
- |
147 |
|
|
|
148 |
subtest 'Koha::Library::Groups->get_root_ancestor' => sub { |
149 |
plan tests => 2; |
150 |
|
151 |
my $groupY = Koha::Library::Group->new( { title => "Group Y" } )->store(); |
152 |
my $groupY_library1 = Koha::Library::Group->new({ parent_id => $groupY->id, branchcode => $library1->{branchcode} })->store(); |
153 |
my $groupY1 = Koha::Library::Group->new( { parent_id => $groupY->id, title => "Group Y1" } )->store(); |
154 |
my $groupY1_library2 = Koha::Library::Group->new({ parent_id => $groupY1->id, branchcode => $library2->{branchcode} })->store(); |
155 |
my $groupZ = Koha::Library::Group->new({ title => "Group Z" })->store(); |
156 |
my $groupZ1 = Koha::Library::Group->new({ parent_id => $groupZ->id, title => "Group Z1" })->store(); |
157 |
my $groupZ2 = Koha::Library::Group->new({ parent_id => $groupZ1->id, title => "Group Z2" })->store(); |
158 |
my $groupZ2_library2 = Koha::Library::Group->new({ parent_id => $groupZ2->id, branchcode => $library2->{branchcode} })->store(); |
159 |
|
160 |
my $ancestor1 = Koha::Library::Groups->get_root_ancestor($groupY1_library2->unblessed); |
161 |
my $ancestor2 = Koha::Library::Groups->get_root_ancestor($groupZ2_library2->unblessed); |
162 |
|
163 |
is($ancestor1->id, $groupY->id, "Get root ancestor should return group's root ancestor"); |
164 |
ok($ancestor1->id ne $ancestor2->id, "Both root groups should have different ids"); |
165 |
}; |