Bug 11934 - Replace given by if-else statements
To test:
[1] Verify that prove -v t/db_dependent/Circulation_issuingrules.t
passes.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
replaces given-when with if-elsif-else constructs.
Tests still pass and code looks good.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
183d4a55ca
commit
12df62ca33
|
|
@ -61,13 +61,17 @@ is_deeply($loanlength, $default, 'none matches');
|
|||
|
||||
#Set syspref ReturnBeforeExpiry = 1 and useDaysMode = 'Days'
|
||||
$contextmodule->mock('preference', sub {
|
||||
my ($self, $syspref) = @_;
|
||||
given ( $syspref ) {
|
||||
when ("ReturnBeforeExpiry"){ return 1; }
|
||||
when ("useDaysMode"){ return 'Days'; }
|
||||
default{ return; }
|
||||
}
|
||||
});
|
||||
my ($self, $syspref) = @_;
|
||||
if ( $syspref eq "ReturnBeforeExpiry") {
|
||||
return 1;
|
||||
}
|
||||
elsif ( $syspref eq "useDaysMode") {
|
||||
return 'Days';
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
my $dateexpiry = '2013-01-01';
|
||||
|
||||
|
|
@ -76,20 +80,23 @@ my $start_date = DateTime->new({year => 2013, month => 2, day => 9});
|
|||
$dbh->{mock_add_resultset} = $mock_loan_length;
|
||||
my $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower );
|
||||
is($date, $dateexpiry . 'T23:59:00', 'date expiry');
|
||||
|
||||
$dbh->{mock_add_resultset} = $mock_loan_length;
|
||||
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 );
|
||||
|
||||
|
||||
#Set syspref ReturnBeforeExpiry = 1 and useDaysMode != 'Days'
|
||||
$contextmodule->mock('preference', sub {
|
||||
my ($self, $syspref) = @_;
|
||||
given ( $syspref ) {
|
||||
when ("ReturnBeforeExpiry"){ return 1; }
|
||||
when ("useDaysMode"){ return 'noDays'; }
|
||||
default{ return; }
|
||||
}
|
||||
});
|
||||
my ($self, $syspref) = @_;
|
||||
if ( $syspref eq "ReturnBeforeExpiry") {
|
||||
return 1;
|
||||
}
|
||||
elsif ($syspref eq "useDaysMode") {
|
||||
return 'noDays';
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry};
|
||||
$start_date = DateTime->new({year => 2013, month => 2, day => 9});
|
||||
|
|
@ -103,13 +110,17 @@ $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borr
|
|||
|
||||
#Set syspref ReturnBeforeExpiry = 0 and useDaysMode = 'Days'
|
||||
$contextmodule->mock('preference', sub {
|
||||
my ($self, $syspref) = @_;
|
||||
given ( $syspref ) {
|
||||
when ("ReturnBeforeExpiry"){ return 0; }
|
||||
when ("useDaysMode"){ return 'Days'; }
|
||||
default{ return; }
|
||||
}
|
||||
});
|
||||
my ($self, $syspref) = @_;
|
||||
if ( $syspref eq "ReturnBeforeExpiry") {
|
||||
return 0;
|
||||
}
|
||||
elsif ( $syspref eq "useDaysMode") {
|
||||
return 'Days';
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry};
|
||||
$start_date = DateTime->new({year => 2013, month => 2, day => 9});
|
||||
|
|
|
|||
Loading…
Reference in New Issue