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 => 76; |
10 |
use Test::More tests => 77; |
11 |
use Test::Exception; |
11 |
use Test::Exception; |
12 |
|
12 |
|
13 |
use MARC::Record; |
13 |
use MARC::Record; |
Lines 108-114
my $reservedate = $first_hold->reservedate;
Link Here
|
108 |
my $borrowernumber = $first_hold->borrowernumber; |
108 |
my $borrowernumber = $first_hold->borrowernumber; |
109 |
my $branch_1code = $first_hold->branchcode; |
109 |
my $branch_1code = $first_hold->branchcode; |
110 |
my $reserve_id = $first_hold->reserve_id; |
110 |
my $reserve_id = $first_hold->reserve_id; |
111 |
is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); |
111 |
is( dt_from_string($reservedate), dt_from_string, "holds_placed_today should return a valid reserve date"); |
112 |
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); |
112 |
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); |
113 |
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); |
113 |
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); |
114 |
ok($reserve_id, "Test holds_placed_today()"); |
114 |
ok($reserve_id, "Test holds_placed_today()"); |
Lines 942-948
subtest 'CanItemBeReserved / holds_per_day tests' => sub {
Link Here
|
942 |
is_deeply( |
942 |
is_deeply( |
943 |
CanItemBeReserved( $patron, $item_2 ), |
943 |
CanItemBeReserved( $patron, $item_2 ), |
944 |
{ status => 'tooManyReservesToday', limit => 2 }, |
944 |
{ status => 'tooManyReservesToday', limit => 2 }, |
945 |
'Patron cannot a third item with 2 reserves daily cap' |
945 |
'Patron cannot reserve a third item with 2 reserves daily cap' |
946 |
); |
946 |
); |
947 |
|
947 |
|
948 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
948 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
Lines 1705-1711
subtest 'ModReserve can only update expirationdate for found holds' => sub {
Link Here
|
1705 |
|
1705 |
|
1706 |
$hold = Koha::Holds->find($reserve_id); |
1706 |
$hold = Koha::Holds->find($reserve_id); |
1707 |
|
1707 |
|
1708 |
is( $hold->expirationdate, '1981-06-10', |
1708 |
is( dt_from_string( $hold->expirationdate )->ymd, '1981-06-10', |
1709 |
'Found hold expiration date updated correctly' ); |
1709 |
'Found hold expiration date updated correctly' ); |
1710 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
1710 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
1711 |
|
1711 |
|
Lines 1807-1809
subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled o
Link Here
|
1807 |
|
1807 |
|
1808 |
$schema->storage->txn_rollback; |
1808 |
$schema->storage->txn_rollback; |
1809 |
}; |
1809 |
}; |
1810 |
- |
1810 |
|
|
|
1811 |
subtest 'HourBasedHolds' => sub { |
1812 |
plan tests => 4; |
1813 |
$schema->storage->txn_begin; |
1814 |
|
1815 |
my $category = $builder->build({ source => 'Category' }); |
1816 |
my $branch = $builder->build({ source => 'Branch' })->{ branchcode }; |
1817 |
my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } ); |
1818 |
my $itemnumber = $builder->build_sample_item( |
1819 |
{ library => $branch, biblionumber => $biblio->biblionumber } ) |
1820 |
->itemnumber; |
1821 |
|
1822 |
my $borrowernumber = Koha::Patron->new( |
1823 |
{ |
1824 |
firstname => 'firstname', |
1825 |
surname => 'surname', |
1826 |
categorycode => $category->{categorycode}, |
1827 |
branchcode => $branch, |
1828 |
} |
1829 |
)->store->borrowernumber; |
1830 |
|
1831 |
t::lib::Mocks::mock_preference('HourBasedHolds', 1); |
1832 |
|
1833 |
my $reservation_date = DateTime->now->set( hour => 7, minute => 30 ); |
1834 |
my $expiration_date = DateTime->now->set( hour => 19, minute => 30 ); |
1835 |
|
1836 |
my $reserve_id = AddReserve( |
1837 |
{ |
1838 |
branchcode => $branch, |
1839 |
borrowernumber => $borrowernumber, |
1840 |
biblionumber => $biblio->biblionumber, |
1841 |
priority => |
1842 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
1843 |
itemnumber => $itemnumber, |
1844 |
reservation_date => $reservation_date, |
1845 |
expiration_date => $expiration_date, |
1846 |
} |
1847 |
); |
1848 |
|
1849 |
my $hold = Koha::Holds->find($reserve_id); |
1850 |
is( dt_from_string( $hold->reservedate )->hour, 07, "Hold reserve date is set correctly with hours when HourBasedHolds enabled" ); |
1851 |
is( dt_from_string( $hold->expirationdate )->hour, 19, "Hold expiration date is set correctly with hours when HourBasedHolds enabled" ); |
1852 |
|
1853 |
t::lib::Mocks::mock_preference('HourBasedHolds', 0); |
1854 |
|
1855 |
$reservation_date = DateTime->now->ymd; |
1856 |
$expiration_date = DateTime->now->ymd; |
1857 |
|
1858 |
$reserve_id = AddReserve( |
1859 |
{ |
1860 |
branchcode => $branch, |
1861 |
borrowernumber => $borrowernumber, |
1862 |
biblionumber => $biblio->biblionumber, |
1863 |
priority => |
1864 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
1865 |
itemnumber => $itemnumber, |
1866 |
reservation_date => $reservation_date, |
1867 |
expiration_date => $expiration_date, |
1868 |
} |
1869 |
); |
1870 |
|
1871 |
$hold = Koha::Holds->find($reserve_id); |
1872 |
is( dt_from_string( $hold->reservedate )->hour, 00, "Hold reserve date is set correctly when HourBasedHolds disabled" ); |
1873 |
is( dt_from_string( $hold->expirationdate )->hour, 23, "Hold expiration date is set correctly when HourBasedHolds disabled" ); |
1874 |
|
1875 |
$schema->storage->txn_rollback; |
1876 |
}; |