|
Lines 339-345
subtest 'pickup_locations' => sub {
Link Here
|
| 339 |
$schema->storage->txn_rollback; |
339 |
$schema->storage->txn_rollback; |
| 340 |
}; |
340 |
}; |
| 341 |
|
341 |
|
| 342 |
subtest '_can_pickup_at' => sub { |
342 |
subtest '_can_pickup_locations' => sub { |
| 343 |
plan tests =>8; |
343 |
plan tests =>8; |
| 344 |
|
344 |
|
| 345 |
$schema->storage->txn_begin; |
345 |
$schema->storage->txn_begin; |
|
Lines 359-365
subtest '_can_pickup_at' => sub {
Link Here
|
| 359 |
|
359 |
|
| 360 |
my @to = ( $library1, $library2, $library3, $library4 ); |
360 |
my @to = ( $library1, $library2, $library3, $library4 ); |
| 361 |
|
361 |
|
| 362 |
my $pickup_locations = $item->_can_pickup_at({ to => \@to }); |
362 |
my $pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 363 |
is( scalar @$pickup_locations, 3, "With no transfer limits we get back the libraries that are pickup locations"); |
363 |
is( scalar @$pickup_locations, 3, "With no transfer limits we get back the libraries that are pickup locations"); |
| 364 |
|
364 |
|
| 365 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
365 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
|
Lines 372-378
subtest '_can_pickup_at' => sub {
Link Here
|
| 372 |
} |
372 |
} |
| 373 |
}); |
373 |
}); |
| 374 |
|
374 |
|
| 375 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
375 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 376 |
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); |
376 |
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); |
| 377 |
|
377 |
|
| 378 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
378 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
|
Lines 383-393
subtest '_can_pickup_at' => sub {
Link Here
|
| 383 |
} |
383 |
} |
| 384 |
}); |
384 |
}); |
| 385 |
|
385 |
|
| 386 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
386 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 387 |
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); |
387 |
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); |
| 388 |
|
388 |
|
| 389 |
t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode'); |
389 |
t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode'); |
| 390 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
390 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 391 |
is( scalar @$pickup_locations, 3, "With no transfer limits of type ccode we get back the libraries that are pickup locations"); |
391 |
is( scalar @$pickup_locations, 3, "With no transfer limits of type ccode we get back the libraries that are pickup locations"); |
| 392 |
|
392 |
|
| 393 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
393 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
|
Lines 398-404
subtest '_can_pickup_at' => sub {
Link Here
|
| 398 |
} |
398 |
} |
| 399 |
}); |
399 |
}); |
| 400 |
|
400 |
|
| 401 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
401 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 402 |
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); |
402 |
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library"); |
| 403 |
|
403 |
|
| 404 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
404 |
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => { |
|
Lines 409-424
subtest '_can_pickup_at' => sub {
Link Here
|
| 409 |
} |
409 |
} |
| 410 |
}); |
410 |
}); |
| 411 |
|
411 |
|
| 412 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
412 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 413 |
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); |
413 |
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries"); |
| 414 |
|
414 |
|
| 415 |
|
415 |
|
| 416 |
$pickup_locations = $item->_can_pickup_at({ to => \@to, from => $library2 }); |
416 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to, from => $library2 }); |
| 417 |
is( scalar @$pickup_locations, 3, "With transfer limits enabled but not applying because of 'from' we get back the libraries that are pickup locations"); |
417 |
is( scalar @$pickup_locations, 3, "With transfer limits enabled but not applying because of 'from' we get back the libraries that are pickup locations"); |
| 418 |
|
418 |
|
| 419 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0); |
419 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0); |
| 420 |
|
420 |
|
| 421 |
$pickup_locations = $item->_can_pickup_at({ to => \@to }); |
421 |
$pickup_locations = $item->_can_pickup_locations({ to => \@to }); |
| 422 |
is( scalar @$pickup_locations, 3, "With transfer limits disabled we get back the libraries that are pickup locations"); |
422 |
is( scalar @$pickup_locations, 3, "With transfer limits disabled we get back the libraries that are pickup locations"); |
| 423 |
|
423 |
|
| 424 |
}; |
424 |
}; |
| 425 |
- |
|
|