View | Details | Raw Unified | Return to bug 22284
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-1 / +1 lines)
Lines 191-197 sub pickup_locations { Link Here
191
191
192
    my %seen;
192
    my %seen;
193
    @pickup_locations =
193
    @pickup_locations =
194
      grep { !$seen{ $_->{branchcode} }++ } @pickup_locations;
194
      grep { !$seen{ $_->branchcode }++ } @pickup_locations;
195
195
196
    return wantarray ? @pickup_locations : \@pickup_locations;
196
    return wantarray ? @pickup_locations : \@pickup_locations;
197
}
197
}
(-)a/Koha/Item.pm (-1 / +1 lines)
Lines 342-348 sub pickup_locations { Link Here
342
    my @pickup_locations;
342
    my @pickup_locations;
343
    foreach my $library (@libs) {
343
    foreach my $library (@libs) {
344
        if ($library->pickup_location && $self->can_be_transferred({ to => $library })) {
344
        if ($library->pickup_location && $self->can_be_transferred({ to => $library })) {
345
            push @pickup_locations, $library->unblessed;
345
            push @pickup_locations, $library;
346
        }
346
        }
347
    }
347
    }
348
348
(-)a/Koha/Libraries.pm (-4 / +4 lines)
Lines 44-50 Koha::Libraries - Koha Library Object set class Link Here
44
44
45
=head3 pickup_locations
45
=head3 pickup_locations
46
46
47
Returns available pickup locations for
47
Returns available pickup locations (Koha::Library objects) for
48
    A. a specific item
48
    A. a specific item
49
    B. a biblio
49
    B. a biblio
50
    C. none of the above, simply all libraries with pickup_location => 1
50
    C. none of the above, simply all libraries with pickup_location => 1
Lines 86-102 sub pickup_locations { Link Here
86
        order_by => ['branchname']
86
        order_by => ['branchname']
87
    });
87
    });
88
88
89
    return $libraries->unblessed unless $item or $biblio;
89
    return $libraries unless $item or $biblio;
90
    if($item) {
90
    if($item) {
91
        unless (ref($item) eq 'Koha::Item') {
91
        unless (ref($item) eq 'Koha::Item') {
92
            $item = Koha::Items->find($item);
92
            $item = Koha::Items->find($item);
93
            return $libraries->unblessed unless $item;
93
            return $libraries unless $item;
94
        }
94
        }
95
        return $item->pickup_locations( {patron => $patron} );
95
        return $item->pickup_locations( {patron => $patron} );
96
    } else {
96
    } else {
97
        unless (ref($biblio) eq 'Koha::Biblio') {
97
        unless (ref($biblio) eq 'Koha::Biblio') {
98
            $biblio = Koha::Biblios->find($biblio);
98
            $biblio = Koha::Biblios->find($biblio);
99
            return $libraries->unblessed unless $biblio;
99
            return $libraries unless $biblio;
100
        }
100
        }
101
        return $biblio->pickup_locations( {patron => $patron} );
101
        return $biblio->pickup_locations( {patron => $patron} );
102
    }
102
    }
(-)a/Koha/Template/Plugin/Branches.pm (-3 / +3 lines)
Lines 90-98 sub pickup_locations { Link Here
90
90
91
    my $search_params = $params->{search_params} || {};
91
    my $search_params = $params->{search_params} || {};
92
    my $selected      = $params->{selected};
92
    my $selected      = $params->{selected};
93
    my $libraries     = Koha::Libraries->pickup_locations($search_params);
93
    my @libraries     = map { $_->unblessed } Koha::Libraries->pickup_locations($search_params);
94
94
95
    for my $l (@$libraries) {
95
    for my $l (@libraries) {
96
        if ( defined $selected and $l->{branchcode} eq $selected
96
        if ( defined $selected and $l->{branchcode} eq $selected
97
            or not defined $selected
97
            or not defined $selected
98
            and C4::Context->userenv
98
            and C4::Context->userenv
Lines 102-108 sub pickup_locations { Link Here
102
        }
102
        }
103
    }
103
    }
104
104
105
    return $libraries;
105
    return \@libraries;
106
}
106
}
107
107
108
1;
108
1;
(-)a/reserve/request.pl (-3 / +9 lines)
Lines 549-555 foreach my $biblionumber (@biblionumbers) { Link Here
549
                $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
549
                $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
550
550
551
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
551
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber )->{status};
552
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved->{status} eq 'OK' );
552
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
553
553
554
                $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
554
                $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
555
555
Lines 566-573 foreach my $biblionumber (@biblionumbers) { Link Here
566
                        $item->{pickup_locations} = 'Any library';
566
                        $item->{pickup_locations} = 'Any library';
567
                        $item->{pickup_locations_code} = 'all';
567
                        $item->{pickup_locations_code} = 'all';
568
                    } else {
568
                    } else {
569
                        $item->{pickup_locations} = join (', ', map { $_->{branchname} } Koha::Items->find($itemnumber)->pickup_locations({ patron => $patron }));
569
                        $item->{pickup_locations} = join( ', ',
570
                        $item->{pickup_locations_code} = join (',', map { $_->{branchcode} } Koha::Items->find($itemnumber)->pickup_locations({ patron => $patron }));
570
                            map { $_->unblessed->{branchname} }
571
                              Koha::Items->find($itemnumber)
572
                              ->pickup_locations( { patron => $patron } ) );
573
                        $item->{pickup_locations_code} = join( ',',
574
                            map { $_->unblessed->{branchcode} }
575
                              Koha::Items->find($itemnumber)
576
                              ->pickup_locations( { patron => $patron } ) );
571
                    }
577
                    }
572
578
573
                    push( @available_itemtypes, $item->{itype} );
579
                    push( @available_itemtypes, $item->{itype} );
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +265 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 7;
20
use Test::More tests => 8;
21
21
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
use Koha::Database;
Lines 170-172 subtest 'is_serial() tests' => sub { Link Here
170
170
171
    $schema->storage->txn_rollback;
171
    $schema->storage->txn_rollback;
172
};
172
};
173
174
subtest 'pickup_locations' => sub {
175
    plan tests => 29;
176
177
    $schema->storage->txn_begin;
178
179
    my $dbh = C4::Context->dbh;
180
181
    # Cleanup database
182
    Koha::Holds->search->delete;
183
    Koha::Patrons->search->delete;
184
    Koha::Items->search->delete;
185
    Koha::Libraries->search->delete;
186
    $dbh->do('DELETE FROM issues');
187
    $dbh->do('DELETE FROM issuingrules');
188
    $dbh->do(
189
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
190
        VALUES (?, ?, ?, ?)},
191
        {},
192
        '*', '*', '*', 25
193
    );
194
    $dbh->do('DELETE FROM circulation_rules');
195
196
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
197
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
198
    my $root3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
199
200
    my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
201
    my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
202
    my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
203
    my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
204
    my $library5 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
205
    my $library6 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
206
    my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
207
    my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
208
209
    Koha::CirculationRules->set_rules(
210
        {
211
            branchcode => $library1->branchcode,
212
            itemtype   => undef,
213
            categorycode => undef,
214
            rules => {
215
                holdallowed => 1,
216
                hold_fulfillment_policy => 'any',
217
                returnbranch => 'any'
218
            }
219
        }
220
    );
221
222
    Koha::CirculationRules->set_rules(
223
        {
224
            branchcode => $library2->branchcode,
225
            itemtype   => undef,
226
            categorycode => undef,
227
            rules => {
228
                holdallowed => 3,
229
                hold_fulfillment_policy => 'holdgroup',
230
                returnbranch => 'any'
231
            }
232
        }
233
    );
234
235
    Koha::CirculationRules->set_rules(
236
        {
237
            branchcode => $library3->branchcode,
238
            itemtype   => undef,
239
            categorycode => undef,
240
            rules => {
241
                holdallowed => 3,
242
                hold_fulfillment_policy => 'patrongroup',
243
                returnbranch => 'any'
244
            }
245
        }
246
    );
247
248
    Koha::CirculationRules->set_rules(
249
        {
250
            branchcode => $library4->branchcode,
251
            itemtype   => undef,
252
            categorycode => undef,
253
            rules => {
254
                holdallowed => 2,
255
                hold_fulfillment_policy => 'holdingbranch',
256
                returnbranch => 'any'
257
            }
258
        }
259
    );
260
261
    Koha::CirculationRules->set_rules(
262
        {
263
            branchcode => $library5->branchcode,
264
            itemtype   => undef,
265
            categorycode => undef,
266
            rules => {
267
                holdallowed => 2,
268
                hold_fulfillment_policy => 'homebranch',
269
                returnbranch => 'any'
270
            }
271
        }
272
    );
273
274
    Koha::CirculationRules->set_rules(
275
        {
276
            branchcode => $library6->branchcode,
277
            itemtype   => undef,
278
            categorycode => undef,
279
            rules => {
280
                holdallowed => 1,
281
                hold_fulfillment_policy => 'holdgroup',
282
                returnbranch => 'any'
283
            }
284
        }
285
    );
286
287
    Koha::CirculationRules->set_rules(
288
        {
289
            branchcode => $library7->branchcode,
290
            itemtype   => undef,
291
            categorycode => undef,
292
            rules => {
293
                holdallowed => 3,
294
                hold_fulfillment_policy => 'holdingbranch',
295
                returnbranch => 'any'
296
            }
297
        }
298
    );
299
300
301
    Koha::CirculationRules->set_rules(
302
        {
303
            branchcode => $library8->branchcode,
304
            itemtype   => undef,
305
            categorycode => undef,
306
            rules => {
307
                holdallowed => 2,
308
                hold_fulfillment_policy => 'patrongroup',
309
                returnbranch => 'any'
310
            }
311
        }
312
    );
313
314
    my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } );
315
    my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } );
316
317
    my $group2_3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
318
    my $group2_4 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
319
320
    my $group3_5 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library5->branchcode } } );
321
    my $group3_6 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library6->branchcode } } );
322
    my $group3_7 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library7->branchcode } } );
323
    my $group3_8 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library8->branchcode } } );
324
325
    my $biblio1  = $builder->build_object( { class => 'Koha::Biblios', value => {title => '1'} } );
326
    my $biblioitem1 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio1->biblionumber } } );
327
    my $biblio2  = $builder->build_object( { class => 'Koha::Biblios', value => {title => '2'} } );
328
    my $biblioitem2 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio2->biblionumber } } );
329
330
    my $item1_1  = Koha::Item->new({
331
        biblionumber     => $biblio1->biblionumber,
332
        biblioitemnumber => $biblioitem1->biblioitemnumber,
333
        homebranch       => $library1->branchcode,
334
        holdingbranch    => $library2->branchcode,
335
        itype            => 'test',
336
        barcode          => "item11barcode",
337
    })->store;
338
339
    my $item1_3  = Koha::Item->new({
340
        biblionumber     => $biblio1->biblionumber,
341
        biblioitemnumber => $biblioitem1->biblioitemnumber,
342
        homebranch       => $library3->branchcode,
343
        holdingbranch    => $library4->branchcode,
344
        itype            => 'test',
345
        barcode          => "item13barcode",
346
    })->store;
347
348
    my $item1_7  = Koha::Item->new({
349
        biblionumber     => $biblio1->biblionumber,
350
        biblioitemnumber => $biblioitem1->biblioitemnumber,
351
        homebranch       => $library7->branchcode,
352
        holdingbranch    => $library4->branchcode,
353
        itype            => 'test',
354
        barcode          => "item17barcode",
355
    })->store;
356
357
    my $item2_2  = Koha::Item->new({
358
        biblionumber     => $biblio2->biblionumber,
359
        biblioitemnumber => $biblioitem2->biblioitemnumber,
360
        homebranch       => $library2->branchcode,
361
        holdingbranch    => $library1->branchcode,
362
        itype            => 'test',
363
        barcode          => "item22barcode",
364
    })->store;
365
366
    my $item2_4  = Koha::Item->new({
367
        biblionumber     => $biblio2->biblionumber,
368
        biblioitemnumber => $biblioitem2->biblioitemnumber,
369
        homebranch       => $library4->branchcode,
370
        holdingbranch    => $library3->branchcode,
371
        itype            => 'test',
372
        barcode          => "item23barcode",
373
    })->store;
374
375
    my $item2_6  = Koha::Item->new({
376
        biblionumber     => $biblio2->biblionumber,
377
        biblioitemnumber => $biblioitem2->biblioitemnumber,
378
        homebranch       => $library6->branchcode,
379
        holdingbranch    => $library4->branchcode,
380
        itype            => 'test',
381
        barcode          => "item26barcode",
382
    })->store;
383
384
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'1', branchcode => $library1->branchcode } } );
385
    my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } );
386
387
    my $results = {
388
        "ItemHomeLibrary-1-1" => 6,
389
        "ItemHomeLibrary-1-8" => 1,
390
        "ItemHomeLibrary-2-1" => 2,
391
        "ItemHomeLibrary-2-8" => 0,
392
        "PatronLibrary-1-1" => 6,
393
        "PatronLibrary-1-8" => 3,
394
        "PatronLibrary-2-1" => 0,
395
        "PatronLibrary-2-8" => 3,
396
    };
397
398
    sub _doTest {
399
        my ( $cbranch, $biblio, $patron, $results ) = @_;
400
        t::lib::Mocks::mock_preference('ReservesControlBranch', $cbranch);
401
402
        my @pl = $biblio->pickup_locations( { patron => $patron} );
403
404
        foreach my $pickup_location (@pl) {
405
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
406
        }
407
408
        ok(
409
            scalar(@pl) == $results->{ $cbranch . '-'
410
                  . $biblio->title . '-'
411
                  . $patron->firstname },
412
            'ReservesControlBranch: '
413
              . $cbranch
414
              . ', biblio'
415
              . $biblio->title
416
              . ', patron'
417
              . $patron->firstname
418
              . ' should return '
419
              . $results->{ $cbranch . '-'
420
                  . $biblio->title . '-'
421
                  . $patron->firstname }
422
              . ' but returns '
423
              . scalar(@pl)
424
        );
425
    }
426
427
    foreach my $cbranch ('ItemHomeLibrary','PatronLibrary') {
428
        foreach my $biblio ($biblio1, $biblio2) {
429
            foreach my $patron ($patron1, $patron8) {
430
                _doTest($cbranch, $biblio, $patron, $results);
431
            }
432
        }
433
    }
434
435
    $schema->storage->txn_rollback;
436
};
(-)a/t/db_dependent/Koha/Biblios.t (-243 lines)
Lines 217-462 subtest 'custom_cover_image_url' => sub { Link Here
217
};
217
};
218
218
219
$schema->storage->txn_rollback;
219
$schema->storage->txn_rollback;
220
221
222
subtest 'pickup_locations' => sub {
223
    plan tests => 8;
224
225
    $schema->storage->txn_begin;
226
227
    # Cleanup database
228
    Koha::Holds->search->delete;
229
    Koha::Patrons->search->delete;
230
    Koha::Items->search->delete;
231
    Koha::Libraries->search->delete;
232
    $dbh->do('DELETE FROM issues');
233
    $dbh->do('DELETE FROM issuingrules');
234
    $dbh->do(
235
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
236
        VALUES (?, ?, ?, ?)},
237
        {},
238
        '*', '*', '*', 25
239
    );
240
    $dbh->do('DELETE FROM circulation_rules');
241
242
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
243
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
244
    my $root3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
245
246
    my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
247
    my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
248
    my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
249
    my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
250
    my $library5 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
251
    my $library6 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
252
    my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
253
    my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
254
255
    Koha::CirculationRules->set_rules(
256
        {
257
            branchcode => $library1->branchcode,
258
            itemtype   => undef,
259
            categorycode => undef,
260
            rules => {
261
                holdallowed => 1,
262
                hold_fulfillment_policy => 'any',
263
                returnbranch => 'any'
264
            }
265
        }
266
    );
267
268
    Koha::CirculationRules->set_rules(
269
        {
270
            branchcode => $library2->branchcode,
271
            itemtype   => undef,
272
            categorycode => undef,
273
            rules => {
274
                holdallowed => 3,
275
                hold_fulfillment_policy => 'holdgroup',
276
                returnbranch => 'any'
277
            }
278
        }
279
    );
280
281
    Koha::CirculationRules->set_rules(
282
        {
283
            branchcode => $library3->branchcode,
284
            itemtype   => undef,
285
            categorycode => undef,
286
            rules => {
287
                holdallowed => 3,
288
                hold_fulfillment_policy => 'patrongroup',
289
                returnbranch => 'any'
290
            }
291
        }
292
    );
293
294
    Koha::CirculationRules->set_rules(
295
        {
296
            branchcode => $library4->branchcode,
297
            itemtype   => undef,
298
            categorycode => undef,
299
            rules => {
300
                holdallowed => 2,
301
                hold_fulfillment_policy => 'holdingbranch',
302
                returnbranch => 'any'
303
            }
304
        }
305
    );
306
307
    Koha::CirculationRules->set_rules(
308
        {
309
            branchcode => $library5->branchcode,
310
            itemtype   => undef,
311
            categorycode => undef,
312
            rules => {
313
                holdallowed => 2,
314
                hold_fulfillment_policy => 'homebranch',
315
                returnbranch => 'any'
316
            }
317
        }
318
    );
319
320
    Koha::CirculationRules->set_rules(
321
        {
322
            branchcode => $library6->branchcode,
323
            itemtype   => undef,
324
            categorycode => undef,
325
            rules => {
326
                holdallowed => 1,
327
                hold_fulfillment_policy => 'holdgroup',
328
                returnbranch => 'any'
329
            }
330
        }
331
    );
332
333
    Koha::CirculationRules->set_rules(
334
        {
335
            branchcode => $library7->branchcode,
336
            itemtype   => undef,
337
            categorycode => undef,
338
            rules => {
339
                holdallowed => 3,
340
                hold_fulfillment_policy => 'holdingbranch',
341
                returnbranch => 'any'
342
            }
343
        }
344
    );
345
346
347
    Koha::CirculationRules->set_rules(
348
        {
349
            branchcode => $library8->branchcode,
350
            itemtype   => undef,
351
            categorycode => undef,
352
            rules => {
353
                holdallowed => 2,
354
                hold_fulfillment_policy => 'patrongroup',
355
                returnbranch => 'any'
356
            }
357
        }
358
    );
359
360
    my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } );
361
    my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } );
362
363
    my $group2_3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
364
    my $group2_4 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
365
366
    my $group3_5 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library5->branchcode } } );
367
    my $group3_6 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library6->branchcode } } );
368
    my $group3_7 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library7->branchcode } } );
369
    my $group3_8 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library8->branchcode } } );
370
371
    my $biblio1  = $builder->build_object( { class => 'Koha::Biblios', value => {title => '1'} } );
372
    my $biblioitem1 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio1->biblionumber } } );
373
    my $biblio2  = $builder->build_object( { class => 'Koha::Biblios', value => {title => '2'} } );
374
    my $biblioitem2 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio2->biblionumber } } );
375
376
    my $item1_1  = Koha::Item->new({
377
        biblionumber     => $biblio1->biblionumber,
378
        biblioitemnumber => $biblioitem1->biblioitemnumber,
379
        homebranch       => $library1->branchcode,
380
        holdingbranch    => $library2->branchcode,
381
        itype            => 'test',
382
        barcode          => "item11barcode",
383
    })->store;
384
385
    my $item1_3  = Koha::Item->new({
386
        biblionumber     => $biblio1->biblionumber,
387
        biblioitemnumber => $biblioitem1->biblioitemnumber,
388
        homebranch       => $library3->branchcode,
389
        holdingbranch    => $library4->branchcode,
390
        itype            => 'test',
391
        barcode          => "item13barcode",
392
    })->store;
393
394
    my $item1_7  = Koha::Item->new({
395
        biblionumber     => $biblio1->biblionumber,
396
        biblioitemnumber => $biblioitem1->biblioitemnumber,
397
        homebranch       => $library7->branchcode,
398
        holdingbranch    => $library4->branchcode,
399
        itype            => 'test',
400
        barcode          => "item17barcode",
401
    })->store;
402
403
    my $item2_2  = Koha::Item->new({
404
        biblionumber     => $biblio2->biblionumber,
405
        biblioitemnumber => $biblioitem2->biblioitemnumber,
406
        homebranch       => $library2->branchcode,
407
        holdingbranch    => $library1->branchcode,
408
        itype            => 'test',
409
        barcode          => "item22barcode",
410
    })->store;
411
412
    my $item2_4  = Koha::Item->new({
413
        biblionumber     => $biblio2->biblionumber,
414
        biblioitemnumber => $biblioitem2->biblioitemnumber,
415
        homebranch       => $library4->branchcode,
416
        holdingbranch    => $library3->branchcode,
417
        itype            => 'test',
418
        barcode          => "item23barcode",
419
    })->store;
420
421
    my $item2_6  = Koha::Item->new({
422
        biblionumber     => $biblio2->biblionumber,
423
        biblioitemnumber => $biblioitem2->biblioitemnumber,
424
        homebranch       => $library6->branchcode,
425
        holdingbranch    => $library4->branchcode,
426
        itype            => 'test',
427
        barcode          => "item26barcode",
428
    })->store;
429
430
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'1', branchcode => $library1->branchcode } } );
431
    my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } );
432
433
    my $results = {
434
        "ItemHomeLibrary-1-1" => 6,
435
        "ItemHomeLibrary-1-8" => 1,
436
        "ItemHomeLibrary-2-1" => 2,
437
        "ItemHomeLibrary-2-8" => 0,
438
        "PatronLibrary-1-1" => 6,
439
        "PatronLibrary-1-8" => 3,
440
        "PatronLibrary-2-1" => 0,
441
        "PatronLibrary-2-8" => 3,
442
    };
443
444
    sub _doTest {
445
        my ( $cbranch, $biblio, $patron, $results ) = @_;
446
        t::lib::Mocks::mock_preference('ReservesControlBranch', $cbranch);
447
448
        my @pl = $biblio->pickup_locations( { patron => $patron} );
449
450
        ok(scalar(@pl) == $results->{$cbranch.'-'.$biblio->title.'-'.$patron->firstname}, 'ReservesControlBranch: '.$cbranch.', biblio'.$biblio->title.', patron'.$patron->firstname.' should return '.$results->{$cbranch.'-'.$biblio->title.'-'.$patron->firstname}.' but returns '.scalar(@pl));
451
    }
452
453
    foreach my $cbranch ('ItemHomeLibrary','PatronLibrary') {
454
        foreach my $biblio ($biblio1, $biblio2) {
455
            foreach my $patron ($patron1, $patron8) {
456
                _doTest($cbranch, $biblio, $patron, $results);
457
            }
458
        }
459
    }
460
461
    $schema->storage->txn_rollback;
462
};
(-)a/t/db_dependent/Koha/Item.t (-1 / +188 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
25
Lines 143-145 subtest "as_marc_field() tests" => sub { Link Here
143
143
144
    $schema->storage->txn_rollback;
144
    $schema->storage->txn_rollback;
145
};
145
};
146
147
subtest 'pickup_locations' => sub {
148
    plan tests => 114;
149
150
    $schema->storage->txn_begin;
151
152
    my $dbh = C4::Context->dbh;
153
154
    # Cleanup database
155
    Koha::Holds->search->delete;
156
    Koha::Patrons->search->delete;
157
    Koha::Items->search->delete;
158
    Koha::Libraries->search->delete;
159
    $dbh->do('DELETE FROM issues');
160
    $dbh->do('DELETE FROM issuingrules');
161
    $dbh->do(
162
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
163
        VALUES (?, ?, ?, ?)},
164
        {},
165
        '*', '*', '*', 25
166
    );
167
    $dbh->do('DELETE FROM circulation_rules');
168
169
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
170
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
171
172
    my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
173
    my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
174
    my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
175
    my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
176
177
    my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } );
178
    my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } );
179
180
    my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
181
    my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
182
183
    my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
184
185
    my $item1  = Koha::Item->new({
186
        biblionumber     => $biblioitem->{biblionumber},
187
        biblioitemnumber => $biblioitem->{biblioitemnumber},
188
        homebranch       => $library1->branchcode,
189
        holdingbranch    => $library2->branchcode,
190
        barcode          => '1',
191
        itype            => 'test',
192
    })->store;
193
194
    my $item3  = Koha::Item->new({
195
        biblionumber     => $biblioitem->{biblionumber},
196
        biblioitemnumber => $biblioitem->{biblioitemnumber},
197
        homebranch       => $library3->branchcode,
198
        holdingbranch    => $library4->branchcode,
199
        barcode          => '3',
200
        itype            => 'test',
201
    })->store;
202
203
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } );
204
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
205
206
    my $results = {
207
        "1-1-1-any" => 3,
208
        "1-1-1-holdgroup" => 2,
209
        "1-1-1-patrongroup" => 2,
210
        "1-1-1-homebranch" => 1,
211
        "1-1-1-holdingbranch" => 1,
212
        "1-1-2-any" => 3,
213
        "1-1-2-holdgroup" => 2,
214
        "1-1-2-patrongroup" => 2,
215
        "1-1-2-homebranch" => 1,
216
        "1-1-2-holdingbranch" => 1,
217
        "1-1-3-any" => 3,
218
        "1-1-3-holdgroup" => 2,
219
        "1-1-3-patrongroup" => 2,
220
        "1-1-3-homebranch" => 1,
221
        "1-1-3-holdingbranch" => 1,
222
        "1-4-1-any" => 0,
223
        "1-4-1-holdgroup" => 0,
224
        "1-4-1-patrongroup" => 0,
225
        "1-4-1-homebranch" => 0,
226
        "1-4-1-holdingbranch" => 0,
227
        "1-4-2-any" => 3,
228
        "1-4-2-holdgroup" => 2,
229
        "1-4-2-patrongroup" => 1,
230
        "1-4-2-homebranch" => 1,
231
        "1-4-2-holdingbranch" => 1,
232
        "1-4-3-any" => 0,
233
        "1-4-3-holdgroup" => 0,
234
        "1-4-3-patrongroup" => 0,
235
        "1-4-3-homebranch" => 0,
236
        "1-4-3-holdingbranch" => 0,
237
        "3-1-1-any" => 0,
238
        "3-1-1-holdgroup" => 0,
239
        "3-1-1-patrongroup" => 0,
240
        "3-1-1-homebranch" => 0,
241
        "3-1-1-holdingbranch" => 0,
242
        "3-1-2-any" => 3,
243
        "3-1-2-holdgroup" => 1,
244
        "3-1-2-patrongroup" => 2,
245
        "3-1-2-homebranch" => 0,
246
        "3-1-2-holdingbranch" => 1,
247
        "3-1-3-any" => 0,
248
        "3-1-3-holdgroup" => 0,
249
        "3-1-3-patrongroup" => 0,
250
        "3-1-3-homebranch" => 0,
251
        "3-1-3-holdingbranch" => 0,
252
        "3-4-1-any" => 0,
253
        "3-4-1-holdgroup" => 0,
254
        "3-4-1-patrongroup" => 0,
255
        "3-4-1-homebranch" => 0,
256
        "3-4-1-holdingbranch" => 0,
257
        "3-4-2-any" => 3,
258
        "3-4-2-holdgroup" => 1,
259
        "3-4-2-patrongroup" => 1,
260
        "3-4-2-homebranch" => 0,
261
        "3-4-2-holdingbranch" => 1,
262
        "3-4-3-any" => 3,
263
        "3-4-3-holdgroup" => 1,
264
        "3-4-3-patrongroup" => 1,
265
        "3-4-3-homebranch" => 0,
266
        "3-4-3-holdingbranch" => 1
267
    };
268
269
    sub _doTest {
270
        my ( $item, $patron, $ha, $hfp, $results ) = @_;
271
272
        Koha::CirculationRules->set_rules(
273
            {
274
                branchcode => undef,
275
                itemtype   => undef,
276
                categorycode => undef,
277
                rules => {
278
                    holdallowed => $ha,
279
                    hold_fulfillment_policy => $hfp,
280
                    returnbranch => 'any'
281
                }
282
            }
283
        );
284
        my @pl = $item->pickup_locations( { patron => $patron} );
285
        my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch');
286
287
        foreach my $pickup_location (@pl) {
288
            is( ref($pickup_location), 'Koha::Library', 'Object type is correct' );
289
        }
290
291
        ok(
292
            scalar(@pl) == $results->{
293
                    $item->barcode . '-'
294
                  . $patron->firstname . '-'
295
                  . $ha . '-'
296
                  . $hfp
297
            },
298
            'item'
299
              . $item->barcode
300
              . ', patron'
301
              . $patron->firstname
302
              . ', holdallowed: '
303
              . $ha_value
304
              . ', hold_fulfillment_policy: '
305
              . $hfp
306
              . ' should return '
307
              . $results->{
308
                    $item->barcode . '-'
309
                  . $patron->firstname . '-'
310
                  . $ha . '-'
311
                  . $hfp
312
              }
313
              . ' but returns '
314
              . scalar(@pl)
315
        );
316
317
    }
318
319
320
    foreach my $item ($item1, $item3) {
321
        foreach my $patron ($patron1, $patron4) {
322
            #holdallowed 1: homebranch, 2: any, 3: holdgroup
323
            foreach my $ha (1, 2, 3) {
324
                foreach my $hfp ('any', 'holdgroup', 'patrongroup', 'homebranch', 'holdingbranch') {
325
                    _doTest($item, $patron, $ha, $hfp, $results);
326
                }
327
            }
328
        }
329
    }
330
331
    $schema->storage->txn_rollback;
332
};
(-)a/t/db_dependent/Koha/Items.t (-157 / +1 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 10;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use C4::Circulation;
25
use C4::Circulation;
Lines 177-335 $retrieved_item_1->delete; Link Here
177
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
177
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
178
178
179
$schema->storage->txn_rollback;
179
$schema->storage->txn_rollback;
180
181
subtest 'pickup_locations' => sub {
182
    plan tests => 60;
183
184
    $schema->storage->txn_begin;
185
186
    # Cleanup database
187
    Koha::Holds->search->delete;
188
    Koha::Patrons->search->delete;
189
    Koha::Items->search->delete;
190
    Koha::Libraries->search->delete;
191
    $dbh->do('DELETE FROM issues');
192
    $dbh->do('DELETE FROM issuingrules');
193
    $dbh->do(
194
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
195
        VALUES (?, ?, ?, ?)},
196
        {},
197
        '*', '*', '*', 25
198
    );
199
    $dbh->do('DELETE FROM circulation_rules');
200
201
    my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
202
    my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } );
203
204
    my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
205
    my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
206
    my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } );
207
    my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } );
208
209
    my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } );
210
    my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } );
211
212
    my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } );
213
    my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } );
214
215
    my $biblioitem  = $builder->build( { source => 'Biblioitem' } );
216
217
    my $item1  = Koha::Item->new({
218
        biblionumber     => $biblioitem->{biblionumber},
219
        biblioitemnumber => $biblioitem->{biblioitemnumber},
220
        homebranch       => $library1->branchcode,
221
        holdingbranch    => $library2->branchcode,
222
        barcode          => '1',
223
        itype            => 'test',
224
    })->store;
225
226
    my $item3  = Koha::Item->new({
227
        biblionumber     => $biblioitem->{biblionumber},
228
        biblioitemnumber => $biblioitem->{biblioitemnumber},
229
        homebranch       => $library3->branchcode,
230
        holdingbranch    => $library4->branchcode,
231
        barcode          => '3',
232
        itype            => 'test',
233
    })->store;
234
235
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } );
236
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
237
238
    my $results = {
239
        "1-1-1-any" => 3,
240
        "1-1-1-holdgroup" => 2,
241
        "1-1-1-patrongroup" => 2,
242
        "1-1-1-homebranch" => 1,
243
        "1-1-1-holdingbranch" => 1,
244
        "1-1-2-any" => 3,
245
        "1-1-2-holdgroup" => 2,
246
        "1-1-2-patrongroup" => 2,
247
        "1-1-2-homebranch" => 1,
248
        "1-1-2-holdingbranch" => 1,
249
        "1-1-3-any" => 3,
250
        "1-1-3-holdgroup" => 2,
251
        "1-1-3-patrongroup" => 2,
252
        "1-1-3-homebranch" => 1,
253
        "1-1-3-holdingbranch" => 1,
254
        "1-4-1-any" => 0,
255
        "1-4-1-holdgroup" => 0,
256
        "1-4-1-patrongroup" => 0,
257
        "1-4-1-homebranch" => 0,
258
        "1-4-1-holdingbranch" => 0,
259
        "1-4-2-any" => 3,
260
        "1-4-2-holdgroup" => 2,
261
        "1-4-2-patrongroup" => 1,
262
        "1-4-2-homebranch" => 1,
263
        "1-4-2-holdingbranch" => 1,
264
        "1-4-3-any" => 0,
265
        "1-4-3-holdgroup" => 0,
266
        "1-4-3-patrongroup" => 0,
267
        "1-4-3-homebranch" => 0,
268
        "1-4-3-holdingbranch" => 0,
269
        "3-1-1-any" => 0,
270
        "3-1-1-holdgroup" => 0,
271
        "3-1-1-patrongroup" => 0,
272
        "3-1-1-homebranch" => 0,
273
        "3-1-1-holdingbranch" => 0,
274
        "3-1-2-any" => 3,
275
        "3-1-2-holdgroup" => 1,
276
        "3-1-2-patrongroup" => 2,
277
        "3-1-2-homebranch" => 0,
278
        "3-1-2-holdingbranch" => 1,
279
        "3-1-3-any" => 0,
280
        "3-1-3-holdgroup" => 0,
281
        "3-1-3-patrongroup" => 0,
282
        "3-1-3-homebranch" => 0,
283
        "3-1-3-holdingbranch" => 0,
284
        "3-4-1-any" => 0,
285
        "3-4-1-holdgroup" => 0,
286
        "3-4-1-patrongroup" => 0,
287
        "3-4-1-homebranch" => 0,
288
        "3-4-1-holdingbranch" => 0,
289
        "3-4-2-any" => 3,
290
        "3-4-2-holdgroup" => 1,
291
        "3-4-2-patrongroup" => 1,
292
        "3-4-2-homebranch" => 0,
293
        "3-4-2-holdingbranch" => 1,
294
        "3-4-3-any" => 3,
295
        "3-4-3-holdgroup" => 1,
296
        "3-4-3-patrongroup" => 1,
297
        "3-4-3-homebranch" => 0,
298
        "3-4-3-holdingbranch" => 1
299
    };
300
301
    sub _doTest {
302
        my ( $item, $patron, $ha, $hfp, $results ) = @_;
303
304
        Koha::CirculationRules->set_rules(
305
            {
306
                branchcode => undef,
307
                itemtype   => undef,
308
                categorycode => undef,
309
                rules => {
310
                    holdallowed => $ha,
311
                    hold_fulfillment_policy => $hfp,
312
                    returnbranch => 'any'
313
                }
314
            }
315
        );
316
        my @pl = $item->pickup_locations( { patron => $patron} );
317
        my $ha_value=$ha==3?'holdgroup':($ha==2?'any':'homebranch');
318
319
        ok(scalar(@pl) == $results->{$item->barcode.'-'.$patron->firstname.'-'.$ha.'-'.$hfp}, 'item'.$item->barcode.', patron'.$patron->firstname.', holdallowed: '.$ha_value.', hold_fulfillment_policy: '.$hfp.' should return '.$results->{$item->barcode.'-'.$patron->firstname.'-'.$ha.'-'.$hfp}.' but returns '.scalar(@pl));
320
    }
321
322
323
    foreach my $item ($item1, $item3) {
324
        foreach my $patron ($patron1, $patron4) {
325
            #holdallowed 1: homebranch, 2: any, 3: holdgroup
326
            foreach my $ha (1, 2, 3) {
327
                foreach my $hfp ('any', 'holdgroup', 'patrongroup', 'homebranch', 'holdingbranch') {
328
                    _doTest($item, $patron, $ha, $hfp, $results);
329
                }
330
            }
331
        }
332
    }
333
334
    $schema->storage->txn_rollback;
335
};
(-)a/t/db_dependent/Koha/Libraries.t (-18 / +17 lines)
Lines 192-198 subtest 'pickup_locations' => sub { Link Here
192
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
192
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
193
            my $found = 0;
193
            my $found = 0;
194
            foreach my $lib (@{$pickup}) {
194
            foreach my $lib (@{$pickup}) {
195
                if ($lib->{'branchcode'} eq $limit->toBranch) {
195
                if ($lib->branchcode eq $limit->toBranch) {
196
                    $found = 1;
196
                    $found = 1;
197
                }
197
                }
198
            }
198
            }
Lines 201-207 subtest 'pickup_locations' => sub { Link Here
201
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
201
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
202
            $found = 0;
202
            $found = 0;
203
            foreach my $lib (@{$pickup}) {
203
            foreach my $lib (@{$pickup}) {
204
                if ($lib->{'branchcode'} eq $limit->toBranch) {
204
                if ($lib->branchcode eq $limit->toBranch) {
205
                    $found = 1;
205
                    $found = 1;
206
                }
206
                }
207
            }
207
            }
Lines 221-227 subtest 'pickup_locations' => sub { Link Here
221
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1  });
221
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1  });
222
            $found = 0;
222
            $found = 0;
223
            foreach my $lib (@{$pickup}) {
223
            foreach my $lib (@{$pickup}) {
224
                if ($lib->{'branchcode'} eq $limit->toBranch) {
224
                if ($lib->branchcode eq $limit->toBranch) {
225
                    $found = 1;
225
                    $found = 1;
226
                }
226
                }
227
            }
227
            }
Lines 230-236 subtest 'pickup_locations' => sub { Link Here
230
            $pickup = Koha::Libraries->pickup_locations({ item => $item2, patron => $patron1 });
230
            $pickup = Koha::Libraries->pickup_locations({ item => $item2, patron => $patron1 });
231
            $found = 0;
231
            $found = 0;
232
            foreach my $lib (@{$pickup}) {
232
            foreach my $lib (@{$pickup}) {
233
                if ($lib->{'branchcode'} eq $limit->toBranch) {
233
                if ($lib->branchcode eq $limit->toBranch) {
234
                    $found = 1;
234
                    $found = 1;
235
                }
235
                }
236
            }
236
            }
Lines 240-246 subtest 'pickup_locations' => sub { Link Here
240
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
240
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
241
            $found = 0;
241
            $found = 0;
242
            foreach my $lib (@{$pickup}) {
242
            foreach my $lib (@{$pickup}) {
243
                if ($lib->{'branchcode'} eq $limit->toBranch) {
243
                if ($lib->branchcode eq $limit->toBranch) {
244
                    $found = 1;
244
                    $found = 1;
245
                }
245
                }
246
            }
246
            }
Lines 249-255 subtest 'pickup_locations' => sub { Link Here
249
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
249
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
250
            $found = 0;
250
            $found = 0;
251
            foreach my $lib (@{$pickup}) {
251
            foreach my $lib (@{$pickup}) {
252
                if ($lib->{'branchcode'} eq $limit->toBranch) {
252
                if ($lib->branchcode eq $limit->toBranch) {
253
                    $found = 1;
253
                    $found = 1;
254
                }
254
                }
255
            }
255
            }
Lines 278-284 subtest 'pickup_locations' => sub { Link Here
278
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
278
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
279
            my $found = 0;
279
            my $found = 0;
280
            foreach my $lib (@{$pickup}) {
280
            foreach my $lib (@{$pickup}) {
281
                if ($lib->{'branchcode'} eq $limit->toBranch) {
281
                if ($lib->branchcode eq $limit->toBranch) {
282
                    $found = 1;
282
                    $found = 1;
283
                }
283
                }
284
            }
284
            }
Lines 287-293 subtest 'pickup_locations' => sub { Link Here
287
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
287
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
288
            $found = 0;
288
            $found = 0;
289
            foreach my $lib (@{$pickup}) {
289
            foreach my $lib (@{$pickup}) {
290
                if ($lib->{'branchcode'} eq $limit->toBranch) {
290
                if ($lib->branchcode eq $limit->toBranch) {
291
                    $found = 1;
291
                    $found = 1;
292
                }
292
                }
293
            }
293
            }
Lines 302-308 subtest 'pickup_locations' => sub { Link Here
302
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
302
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
303
            $found = 0;
303
            $found = 0;
304
            foreach my $lib (@{$pickup}) {
304
            foreach my $lib (@{$pickup}) {
305
                if ($lib->{'branchcode'} eq $limit->toBranch) {
305
                if ($lib->branchcode eq $limit->toBranch) {
306
                    $found = 1;
306
                    $found = 1;
307
                }
307
                }
308
            }
308
            }
Lines 319-325 subtest 'pickup_locations' => sub { Link Here
319
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
319
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
320
            $found = 0;
320
            $found = 0;
321
            foreach my $lib (@{$pickup}) {
321
            foreach my $lib (@{$pickup}) {
322
                if ($lib->{'branchcode'} eq $limit->toBranch) {
322
                if ($lib->branchcode eq $limit->toBranch) {
323
                    $found = 1;
323
                    $found = 1;
324
                }
324
                }
325
            }
325
            }
Lines 328-334 subtest 'pickup_locations' => sub { Link Here
328
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
328
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
329
            $found = 0;
329
            $found = 0;
330
            foreach my $lib (@{$pickup}) {
330
            foreach my $lib (@{$pickup}) {
331
                if ($lib->{'branchcode'} eq $limit->toBranch) {
331
                if ($lib->branchcode eq $limit->toBranch) {
332
                    $found = 1;
332
                    $found = 1;
333
                }
333
                }
334
            }
334
            }
Lines 355-361 subtest 'pickup_locations' => sub { Link Here
355
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
355
            my $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
356
            my $found = 0;
356
            my $found = 0;
357
            foreach my $lib (@{$pickup}) {
357
            foreach my $lib (@{$pickup}) {
358
                if ($lib->{'branchcode'} eq $limit->toBranch) {
358
                if ($lib->branchcode eq $limit->toBranch) {
359
                    $found = 1;
359
                    $found = 1;
360
                }
360
                }
361
            }
361
            }
Lines 364-370 subtest 'pickup_locations' => sub { Link Here
364
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
364
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
365
            $found = 0;
365
            $found = 0;
366
            foreach my $lib (@{$pickup}) {
366
            foreach my $lib (@{$pickup}) {
367
                if ($lib->{'branchcode'} eq $limit->toBranch) {
367
                if ($lib->branchcode eq $limit->toBranch) {
368
                    $found = 1;
368
                    $found = 1;
369
                }
369
                }
370
            }
370
            }
Lines 384-390 subtest 'pickup_locations' => sub { Link Here
384
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
384
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
385
            $found = 0;
385
            $found = 0;
386
            foreach my $lib (@{$pickup}) {
386
            foreach my $lib (@{$pickup}) {
387
                if ($lib->{'branchcode'} eq $limit->toBranch) {
387
                if ($lib->branchcode eq $limit->toBranch) {
388
                    $found = 1;
388
                    $found = 1;
389
                }
389
                }
390
            }
390
            }
Lines 393-399 subtest 'pickup_locations' => sub { Link Here
393
            $pickup = Koha::Libraries->pickup_locations({ item => $item3, patron => $patron1 });
393
            $pickup = Koha::Libraries->pickup_locations({ item => $item3, patron => $patron1 });
394
            $found = 0;
394
            $found = 0;
395
            foreach my $lib (@{$pickup}) {
395
            foreach my $lib (@{$pickup}) {
396
                if ($lib->{'branchcode'} eq $limit->toBranch) {
396
                if ($lib->branchcode eq $limit->toBranch) {
397
                    $found = 1;
397
                    $found = 1;
398
                }
398
                }
399
            }
399
            }
Lines 403-409 subtest 'pickup_locations' => sub { Link Here
403
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
403
            $pickup = Koha::Libraries->pickup_locations({ biblio => $biblio->biblionumber, patron => $patron1 });
404
            $found = 0;
404
            $found = 0;
405
            foreach my $lib (@{$pickup}) {
405
            foreach my $lib (@{$pickup}) {
406
                if ($lib->{'branchcode'} eq $limit->toBranch) {
406
                if ($lib->branchcode eq $limit->toBranch) {
407
                    $found = 1;
407
                    $found = 1;
408
                }
408
                }
409
            }
409
            }
Lines 412-418 subtest 'pickup_locations' => sub { Link Here
412
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
412
            $pickup = Koha::Libraries->pickup_locations({ item => $item1, patron => $patron1 });
413
            $found = 0;
413
            $found = 0;
414
            foreach my $lib (@{$pickup}) {
414
            foreach my $lib (@{$pickup}) {
415
                if ($lib->{'branchcode'} eq $limit->toBranch) {
415
                if ($lib->branchcode eq $limit->toBranch) {
416
                    $found = 1;
416
                    $found = 1;
417
                }
417
                }
418
            }
418
            }
419
- 

Return to bug 22284