Lines 139-159
subtest 'find' => sub {
Link Here
|
139 |
}; |
139 |
}; |
140 |
|
140 |
|
141 |
subtest 'search_related' => sub { |
141 |
subtest 'search_related' => sub { |
142 |
plan tests => 8; |
142 |
plan tests => 6; |
143 |
my $builder = t::lib::TestBuilder->new; |
143 |
my $builder = t::lib::TestBuilder->new; |
144 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
144 |
my $patron_1 = $builder->build( { source => 'Borrower' } ); |
145 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
145 |
my $patron_2 = $builder->build( { source => 'Borrower' } ); |
146 |
my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
146 |
my $libraries = Koha::Patrons->search( |
147 |
is( ref( $libraries ), 'Koha::Libraries', 'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' ); |
147 |
{ |
148 |
is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); |
148 |
-or => { |
149 |
is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
149 |
borrowernumber => |
150 |
is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
150 |
[ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] |
151 |
|
151 |
} |
152 |
my @libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); |
152 |
} |
153 |
is( ref( $libraries[0] ), 'Koha::Library', 'Koha::Objects->search_related should return a list of Koha::Object-based objects' ); |
153 |
)->search_related('branchcode'); |
154 |
is( scalar(@libraries), 2, 'Koha::Objects->search_related should work as expected' ); |
154 |
is( ref($libraries), 'Koha::Libraries', |
155 |
is( $libraries[0]->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
155 |
'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' |
156 |
is( $libraries[1]->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); |
156 |
); |
|
|
157 |
is( $libraries->count, 2, |
158 |
'Koha::Objects->search_related should work as expected' ); |
159 |
ok( eq_array( |
160 |
[ $libraries->get_column('branchcode') ], |
161 |
[ $patron_1->{branchcode}, $patron_2->{branchcode} ] ), |
162 |
'Koha::Objects->search_related should work as expected' |
163 |
); |
164 |
|
165 |
my @libraries = Koha::Patrons->search( |
166 |
{ |
167 |
-or => { |
168 |
borrowernumber => |
169 |
[ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] |
170 |
} |
171 |
} |
172 |
)->search_related('branchcode'); |
173 |
is( |
174 |
ref( $libraries[0] ), 'Koha::Library', |
175 |
'Koha::Objects->search_related should return a list of Koha::Object-based objects' |
176 |
); |
177 |
is( scalar(@libraries), 2, |
178 |
'Koha::Objects->search_related should work as expected' ); |
179 |
ok( eq_array( |
180 |
[ map { $_->branchcode } @libraries ], |
181 |
[ $patron_1->{branchcode}, $patron_2->{branchcode} ] ), |
182 |
'Koha::Objects->search_related should work as expected' |
183 |
); |
157 |
}; |
184 |
}; |
158 |
|
185 |
|
159 |
subtest 'single' => sub { |
186 |
subtest 'single' => sub { |
160 |
- |
|
|