Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 69; |
21 |
use Test::More tests => 70; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 1733-1738
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1733 |
$recall->set_cancelled; |
1733 |
$recall->set_cancelled; |
1734 |
}; |
1734 |
}; |
1735 |
|
1735 |
|
|
|
1736 |
subtest "CanBookBeRenewed | bookings" => sub { |
1737 |
plan tests => 3; |
1738 |
|
1739 |
my $schema = Koha::Database->schema; |
1740 |
$schema->storage->txn_begin; |
1741 |
|
1742 |
t::lib::Mocks::mock_preference('RenewalPeriodBase', 'date_due'); |
1743 |
|
1744 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1745 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1746 |
my $item = $builder->build_sample_item( { bookable => 1 } ); |
1747 |
|
1748 |
# issue |
1749 |
my $issue = AddIssue( $renewing_patron, $item->barcode ); |
1750 |
my $datedue = dt_from_string( $issue->date_due() ); |
1751 |
is( defined $issue->date_due(), 1, "Item checked out, due date: " . $issue->date_due() ); |
1752 |
|
1753 |
# item-level booking |
1754 |
my $booking = Koha::Booking->new( |
1755 |
{ |
1756 |
patron_id => $booked_patron->borrowernumber, |
1757 |
item_id => $item->itemnumber, |
1758 |
biblio_id => $item->biblio->biblionumber, |
1759 |
start_date => $datedue->clone()->add( days => 2 ), |
1760 |
end_date => $datedue->clone()->add( days => 10 ), |
1761 |
} |
1762 |
)->store(); |
1763 |
|
1764 |
# Proposed renewal would encroach on booking |
1765 |
my ( $renewok, $error ) = CanBookBeRenewed( $renewing_patron, $issue, 0 ); |
1766 |
is( $renewok, 0, "Renewal not allowed as it would mean the item was not returned before the next booking" ); |
1767 |
is( $error, 'booked', "Error is 'booked'" ); |
1768 |
|
1769 |
$schema->storage->txn_rollback; |
1770 |
}; |
1771 |
|
1736 |
subtest "GetUpcomingDueIssues" => sub { |
1772 |
subtest "GetUpcomingDueIssues" => sub { |
1737 |
plan tests => 12; |
1773 |
plan tests => 12; |
1738 |
|
1774 |
|
1739 |
- |
|
|