Bug 12876: Improve unit tests for CanReserveBeCanceledFromOpac
This patch fix the subroutine name and add a restriction on the arguments: both argument are mandatory! Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> Conflicts: t/db_dependent/Reserves.t Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
c0ab862f4a
commit
ea2c5633cd
|
|
@ -571,6 +571,7 @@ sub CanItemBeReserved{
|
|||
sub CanReserveBeCanceledFromOpac {
|
||||
my ($reserve_id, $borrowernumber) = @_;
|
||||
|
||||
return unless $reserve_id and $borrowernumber;
|
||||
my $reserve = GetReserve($reserve_id);
|
||||
|
||||
return 0 unless $reserve->{borrowernumber} == $borrowernumber;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 39;
|
||||
use Test::More tests => 42;
|
||||
|
||||
use MARC::Record;
|
||||
use DateTime::Duration;
|
||||
|
|
@ -402,6 +402,20 @@ AddReserve('CPL', $requesters{'CPL'}, $item_bibnum,
|
|||
$title, $checkitem, '');
|
||||
my (undef, $canres, undef) = CheckReserves($itemnumber);
|
||||
|
||||
is( CanReserveBeCanceledFromOpac(), undef,
|
||||
'CanReserveBeCanceledFromOpac should return undef if called without any parameter'
|
||||
);
|
||||
is(
|
||||
CanReserveBeCanceledFromOpac( $canres->{resserve_id} ),
|
||||
undef,
|
||||
'CanReserveBeCanceledFromOpac should return undef if called without the reserve_id'
|
||||
);
|
||||
is(
|
||||
CanReserveBeCanceledFromOpac( undef, $requesters{CPL} ),
|
||||
undef,
|
||||
'CanReserveBeCanceledFromOpac should return undef if called without borrowernumber'
|
||||
);
|
||||
|
||||
my $cancancel = CanReserveBeCanceledFromOpac($canres->{reserve_id}, $requesters{'CPL'});
|
||||
is($cancancel, 1, 'Can user cancel its own reserve');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue