Lines 7-13
use t::lib::TestBuilder;
Link Here
|
7 |
|
7 |
|
8 |
use C4::Context; |
8 |
use C4::Context; |
9 |
|
9 |
|
10 |
use Test::More tests => 72; |
10 |
use Test::More tests => 73; |
11 |
use MARC::Record; |
11 |
use MARC::Record; |
12 |
|
12 |
|
13 |
use C4::Biblio; |
13 |
use C4::Biblio; |
Lines 102-108
my $reservedate = $first_hold->reservedate;
Link Here
|
102 |
my $borrowernumber = $first_hold->borrowernumber; |
102 |
my $borrowernumber = $first_hold->borrowernumber; |
103 |
my $branch_1code = $first_hold->branchcode; |
103 |
my $branch_1code = $first_hold->branchcode; |
104 |
my $reserve_id = $first_hold->reserve_id; |
104 |
my $reserve_id = $first_hold->reserve_id; |
105 |
is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); |
105 |
is( dt_from_string($reservedate), dt_from_string, "holds_placed_today should return a valid reserve date"); |
106 |
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); |
106 |
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); |
107 |
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); |
107 |
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); |
108 |
ok($reserve_id, "Test holds_placed_today()"); |
108 |
ok($reserve_id, "Test holds_placed_today()"); |
Lines 922-928
subtest 'CanItemBeReserved / holds_per_day tests' => sub {
Link Here
|
922 |
is_deeply( |
922 |
is_deeply( |
923 |
CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ), |
923 |
CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ), |
924 |
{ status => 'tooManyReservesToday', limit => 2 }, |
924 |
{ status => 'tooManyReservesToday', limit => 2 }, |
925 |
'Patron cannot a third item with 2 reserves daily cap' |
925 |
'Patron cannot reserve a third item with 2 reserves daily cap' |
926 |
); |
926 |
); |
927 |
|
927 |
|
928 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
928 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
Lines 1658-1667
subtest 'ModReserve can only update expirationdate for found holds' => sub {
Link Here
|
1658 |
|
1658 |
|
1659 |
$hold = Koha::Holds->find($reserve_id); |
1659 |
$hold = Koha::Holds->find($reserve_id); |
1660 |
|
1660 |
|
1661 |
is( $hold->expirationdate, '1981-06-10', |
1661 |
is( dt_from_string( $hold->expirationdate )->ymd, '1981-06-10', |
1662 |
'Found hold expiration date updated correctly' ); |
1662 |
'Found hold expiration date updated correctly' ); |
1663 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
1663 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
1664 |
|
1664 |
|
1665 |
$schema->storage->txn_rollback; |
1665 |
$schema->storage->txn_rollback; |
1666 |
|
1666 |
|
1667 |
}; |
1667 |
}; |
1668 |
- |
1668 |
|
|
|
1669 |
subtest 'HourBasedHolds' => sub { |
1670 |
plan tests => 4; |
1671 |
$schema->storage->txn_begin; |
1672 |
|
1673 |
my $category = $builder->build({ source => 'Category' }); |
1674 |
my $branch = $builder->build({ source => 'Branch' })->{ branchcode }; |
1675 |
my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } ); |
1676 |
my $itemnumber = $builder->build_sample_item( |
1677 |
{ library => $branch, biblionumber => $biblio->biblionumber } ) |
1678 |
->itemnumber; |
1679 |
|
1680 |
my $borrowernumber = Koha::Patron->new( |
1681 |
{ |
1682 |
firstname => 'firstname', |
1683 |
surname => 'surname', |
1684 |
categorycode => $category->{categorycode}, |
1685 |
branchcode => $branch, |
1686 |
} |
1687 |
)->store->borrowernumber; |
1688 |
|
1689 |
t::lib::Mocks::mock_preference('HourBasedHolds', 1); |
1690 |
|
1691 |
my $reservation_date = DateTime->now->set( hour => 7, minute => 30 ); |
1692 |
my $expiration_date = DateTime->now->set( hour => 19, minute => 30 ); |
1693 |
|
1694 |
my $reserve_id = AddReserve( |
1695 |
{ |
1696 |
branchcode => $branch, |
1697 |
borrowernumber => $borrowernumber, |
1698 |
biblionumber => $biblio->biblionumber, |
1699 |
priority => |
1700 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
1701 |
itemnumber => $itemnumber, |
1702 |
reservation_date => $reservation_date, |
1703 |
expiration_date => $expiration_date, |
1704 |
} |
1705 |
); |
1706 |
|
1707 |
my $hold = Koha::Holds->find($reserve_id); |
1708 |
is( dt_from_string( $hold->reservedate )->hour, 07, "Hold reserve date is set correctly with hours when HourBasedHolds enabled" ); |
1709 |
is( dt_from_string( $hold->expirationdate )->hour, 19, "Hold expiration date is set correctly with hours when HourBasedHolds enabled" ); |
1710 |
|
1711 |
t::lib::Mocks::mock_preference('HourBasedHolds', 0); |
1712 |
|
1713 |
$reservation_date = DateTime->now->ymd; |
1714 |
$expiration_date = DateTime->now->ymd; |
1715 |
|
1716 |
$reserve_id = AddReserve( |
1717 |
{ |
1718 |
branchcode => $branch, |
1719 |
borrowernumber => $borrowernumber, |
1720 |
biblionumber => $biblio->biblionumber, |
1721 |
priority => |
1722 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
1723 |
itemnumber => $itemnumber, |
1724 |
reservation_date => $reservation_date, |
1725 |
expiration_date => $expiration_date, |
1726 |
} |
1727 |
); |
1728 |
|
1729 |
$hold = Koha::Holds->find($reserve_id); |
1730 |
is( dt_from_string( $hold->reservedate )->hour, 00, "Hold reserve date is set correctly when HourBasedHolds disabled" ); |
1731 |
is( dt_from_string( $hold->expirationdate )->hour, 23, "Hold expiration date is set correctly when HourBasedHolds disabled" ); |
1732 |
|
1733 |
$schema->storage->txn_rollback; |
1734 |
}; |