Lines 18-23
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use DateTime; |
20 |
use DateTime; |
|
|
21 |
use Time::HiRes qw( gettimeofday ); |
21 |
use C4::Biblio; |
22 |
use C4::Biblio; |
22 |
use C4::Branch; |
23 |
use C4::Branch; |
23 |
use C4::Items; |
24 |
use C4::Items; |
Lines 26-33
use C4::Reserves;
Link Here
|
26 |
use C4::Overdues qw(UpdateFine); |
27 |
use C4::Overdues qw(UpdateFine); |
27 |
use Koha::DateUtils; |
28 |
use Koha::DateUtils; |
28 |
use Koha::Database; |
29 |
use Koha::Database; |
|
|
30 |
use t::lib::TestBuilder; |
29 |
|
31 |
|
30 |
use Test::More tests => 61; |
32 |
use Test::More tests => 65; |
31 |
|
33 |
|
32 |
BEGIN { |
34 |
BEGIN { |
33 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
Lines 594-599
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
594 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
596 |
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" ); |
595 |
} |
597 |
} |
596 |
|
598 |
|
|
|
599 |
{ |
600 |
my $builder = t::lib::TestBuilder->new(); |
601 |
my $item = $builder->build( { source => 'Item' } ); |
602 |
my $patron = $builder->build( |
603 |
{ source => 'Borrower', |
604 |
value => { dateexpiry => '9999-12-31' } |
605 |
} |
606 |
); |
607 |
$patron->{flags} = C4::Members::patronflags($borrower); |
608 |
my $duration = gettimeofday(); |
609 |
my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
610 |
$duration = gettimeofday() - $duration; |
611 |
cmp_ok $duration, '<', 1, "CanBookBeIssued should not be take more than 1s if the patron is expired"; |
612 |
is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is 9999-*' ); |
613 |
|
614 |
$item = $builder->build( { source => 'Item' } ); |
615 |
$patron = $builder->build( |
616 |
{ source => 'Borrower', |
617 |
value => { dateexpiry => '0000-00-00' } |
618 |
} |
619 |
); |
620 |
$patron->{flags} = C4::Members::patronflags($borrower); |
621 |
( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
622 |
is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' ); |
623 |
|
624 |
my $tomorrow = dt_from_string->add_duration( DateTime::Duration->new( days => 1 ) ); |
625 |
$item = $builder->build( { source => 'Item' } ); |
626 |
$patron = $builder->build( |
627 |
{ source => 'Borrower', |
628 |
value => { dateexpiry => output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ) }, |
629 |
} |
630 |
); |
631 |
$patron->{flags} = C4::Members::patronflags($borrower); |
632 |
( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
633 |
is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' ); |
634 |
} |
635 |
|
597 |
$dbh->rollback; |
636 |
$dbh->rollback; |
598 |
|
637 |
|
599 |
1; |
638 |
1; |
600 |
- |
|
|