}
-=head3 _can_pickup_at
+=head3 _can_pickup_locations
-$item->_can_pickup_at({ to => $to_libraries, from => $from_library })
+$item->_can_pickup_locations({ to => $to_libraries, from => $from_library })
Checks if an item can be transferred to given libraries.
This feature is controlled by two system preferences:
=cut
-sub _can_pickup_at {
+sub _can_pickup_locations {
my ($self, $params ) = @_;
my $to = $params->{to};
})->as_list;
}
- my $pickup_locations = $self->_can_pickup_at({
+ my $pickup_locations = $self->_can_pickup_locations({
to => \@libs
});
$schema->storage->txn_rollback;
};
-subtest '_can_pickup_at' => sub {
+subtest '_can_pickup_locations' => sub {
plan tests =>8;
$schema->storage->txn_begin;
my @to = ( $library1, $library2, $library3, $library4 );
- my $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ my $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 3, "With no transfer limits we get back the libraries that are pickup locations");
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1);
}
});
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library");
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => {
}
});
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries");
t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode');
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 3, "With no transfer limits of type ccode we get back the libraries that are pickup locations");
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => {
}
});
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 2, "With a transfer limits we get back the libraries that are pickup locations minus 1 limited library");
$builder->build_object( { class => 'Koha::Item::Transfer::Limits', value => {
}
});
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 1, "With 2 transfer limits we get back the libraries that are pickup locations minus 2 limited libraries");
- $pickup_locations = $item->_can_pickup_at({ to => \@to, from => $library2 });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to, from => $library2 });
is( scalar @$pickup_locations, 3, "With transfer limits enabled but not applying because of 'from' we get back the libraries that are pickup locations");
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0);
- $pickup_locations = $item->_can_pickup_at({ to => \@to });
+ $pickup_locations = $item->_can_pickup_locations({ to => \@to });
is( scalar @$pickup_locations, 3, "With transfer limits disabled we get back the libraries that are pickup locations");
};