Lines 185-203
subtest 'is_serial() tests' => sub {
Link Here
|
185 |
}; |
185 |
}; |
186 |
|
186 |
|
187 |
subtest 'pickup_locations' => sub { |
187 |
subtest 'pickup_locations' => sub { |
188 |
plan tests => 29; |
188 |
plan tests => 8; |
189 |
|
189 |
|
190 |
$schema->storage->txn_begin; |
190 |
$schema->storage->txn_begin; |
191 |
|
191 |
|
192 |
my $dbh = C4::Context->dbh; |
192 |
my $nb_libraries = Koha::Libraries->count; |
193 |
|
|
|
194 |
# Cleanup database |
195 |
Koha::Holds->search->delete; |
196 |
Koha::Patrons->search->delete; |
197 |
Koha::Items->search->delete; |
198 |
Koha::Libraries->search->delete; |
199 |
Koha::CirculationRules->search->delete; |
193 |
Koha::CirculationRules->search->delete; |
200 |
$dbh->do('DELETE FROM issues'); |
|
|
201 |
Koha::CirculationRules->set_rules( |
194 |
Koha::CirculationRules->set_rules( |
202 |
{ |
195 |
{ |
203 |
categorycode => undef, |
196 |
categorycode => undef, |
Lines 222-227
subtest 'pickup_locations' => sub {
Link Here
|
222 |
my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
215 |
my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
223 |
my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } ); |
216 |
my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } ); |
224 |
|
217 |
|
|
|
218 |
our @branchcodes = map { $_->branchcode } ($library1, $library2, $library3, $library4, $library5, $library6, $library7, $library8); |
219 |
|
225 |
Koha::CirculationRules->set_rules( |
220 |
Koha::CirculationRules->set_rules( |
226 |
{ |
221 |
{ |
227 |
branchcode => $library1->branchcode, |
222 |
branchcode => $library1->branchcode, |
Lines 373-383
subtest 'pickup_locations' => sub {
Link Here
|
373 |
my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } ); |
368 |
my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } ); |
374 |
|
369 |
|
375 |
my $results = { |
370 |
my $results = { |
376 |
"ItemHomeLibrary-1-1" => 6, |
371 |
"ItemHomeLibrary-1-1" => 6 + $nb_libraries, |
377 |
"ItemHomeLibrary-1-8" => 1, |
372 |
"ItemHomeLibrary-1-8" => 1, |
378 |
"ItemHomeLibrary-2-1" => 2, |
373 |
"ItemHomeLibrary-2-1" => 2, |
379 |
"ItemHomeLibrary-2-8" => 0, |
374 |
"ItemHomeLibrary-2-8" => 0, |
380 |
"PatronLibrary-1-1" => 6, |
375 |
"PatronLibrary-1-1" => 6 + $nb_libraries, |
381 |
"PatronLibrary-1-8" => 3, |
376 |
"PatronLibrary-1-8" => 3, |
382 |
"PatronLibrary-2-1" => 0, |
377 |
"PatronLibrary-2-1" => 0, |
383 |
"PatronLibrary-2-8" => 3, |
378 |
"PatronLibrary-2-8" => 3, |
Lines 390-395
subtest 'pickup_locations' => sub {
Link Here
|
390 |
my @pl = @{ $biblio->pickup_locations( { patron => $patron} ) }; |
385 |
my @pl = @{ $biblio->pickup_locations( { patron => $patron} ) }; |
391 |
|
386 |
|
392 |
foreach my $pickup_location (@pl) { |
387 |
foreach my $pickup_location (@pl) { |
|
|
388 |
next |
389 |
unless grep { $pickup_location eq $_ } @branchcodes; |
390 |
|
393 |
is( ref($pickup_location), 'Koha::Library', 'Object type is correct' ); |
391 |
is( ref($pickup_location), 'Koha::Library', 'Object type is correct' ); |
394 |
} |
392 |
} |
395 |
|
393 |
|