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 => 15; |
8 |
|
8 |
|
9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
10 |
|
10 |
|
Lines 20-45
$dbh->{AutoCommit} = 0;
Link Here
|
20 |
$dbh->{RaiseError} = 1; |
20 |
$dbh->{RaiseError} = 1; |
21 |
|
21 |
|
22 |
$dbh->do(q|DELETE FROM issues|); |
22 |
$dbh->do(q|DELETE FROM issues|); |
|
|
23 |
$dbh->do(q|DELETE FROM library_groups|); |
23 |
|
24 |
|
24 |
my $builder = t::lib::TestBuilder->new(); |
25 |
my $builder = t::lib::TestBuilder->new(); |
25 |
|
26 |
|
26 |
my $library1 = $builder->build( |
27 |
my $library1 = $builder->build( { source => 'Branch' } ); |
27 |
{ |
28 |
my $library2 = $builder->build( { source => 'Branch' } ); |
28 |
source => 'Branch', |
29 |
my $library3 = $builder->build( { source => 'Branch' } ); |
29 |
} |
30 |
my $library4 = $builder->build( { source => 'Branch' } ); |
30 |
); |
31 |
my $library5 = $builder->build( { source => 'Branch' } ); |
31 |
|
32 |
my $library6 = $builder->build( { source => 'Branch' } ); |
32 |
my $library2 = $builder->build( |
33 |
my $library7 = $builder->build( { source => 'Branch' } ); |
33 |
{ |
|
|
34 |
source => 'Branch', |
35 |
} |
36 |
); |
37 |
|
38 |
my $library3 = $builder->build( |
39 |
{ |
40 |
source => 'Branch', |
41 |
} |
42 |
); |
43 |
|
34 |
|
44 |
my $root_group = |
35 |
my $root_group = |
45 |
Koha::Library::Group->new( { title => "Test root group" } )->store(); |
36 |
Koha::Library::Group->new( { title => "Test root group" } )->store(); |
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'); |
68 |
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; |
69 |
$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'); |
70 |
ok( $in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 2 is in the list'); |
80 |
- |
71 |
|
|
|
72 |
my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); |
73 |
my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); |
74 |
my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); |
75 |
my $groupX1 = Koha::Library::Group->new({ parent_id => $groupX->id, title => 'Group X1' })->store(); |
76 |
my $groupX1_library3 = Koha::Library::Group->new({ parent_id => $groupX1->id, branchcode => $library3->{branchcode} })->store(); |
77 |
my $groupX1_library4 = Koha::Library::Group->new({ parent_id => $groupX1->id, branchcode => $library4->{branchcode} })->store(); |
78 |
my $groupX2 = Koha::Library::Group->new({ parent_id => $groupX->id, title => 'Group X2' })->store(); |
79 |
my $groupX2_library5 = Koha::Library::Group->new({ parent_id => $groupX2->id, branchcode => $library5->{branchcode} })->store(); |
80 |
my $groupX2_library6 = Koha::Library::Group->new({ parent_id => $groupX2->id, branchcode => $library6->{branchcode} })->store(); |
81 |
|
82 |
my @branchcodes = sort( $library1->{branchcode}, $library2->{branchcode} ); |
83 |
my @group_branchcodes = sort( map { $_->branchcode } $groupX->libraries->as_list ); |
84 |
is_deeply( \@branchcodes, \@group_branchcodes, "Group libraries are returned correctly" ); |
85 |
|
86 |
@branchcodes = sort( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode}, $library4->{branchcode}, $library5->{branchcode}, $library6->{branchcode} ); |
87 |
@group_branchcodes = sort( map { $_->branchcode } $groupX->all_libraries ); |
88 |
is_deeply( \@branchcodes, \@group_branchcodes, "Group all_libraries are returned correctly" ); |
89 |
|