|
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 => 74; |
10 |
use Test::More tests => 75; |
| 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 939-945
subtest 'CanItemBeReserved / holds_per_day tests' => sub {
Link Here
|
| 939 |
is_deeply( |
939 |
is_deeply( |
| 940 |
CanItemBeReserved( $patron, $item_2 ), |
940 |
CanItemBeReserved( $patron, $item_2 ), |
| 941 |
{ status => 'tooManyReservesToday', limit => 2 }, |
941 |
{ status => 'tooManyReservesToday', limit => 2 }, |
| 942 |
'Patron cannot a third item with 2 reserves daily cap' |
942 |
'Patron cannot reserve a third item with 2 reserves daily cap' |
| 943 |
); |
943 |
); |
| 944 |
|
944 |
|
| 945 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
945 |
# Update last hold so reservedate is in the past, so 2 holds, but different day |
|
Lines 1702-1708
subtest 'ModReserve can only update expirationdate for found holds' => sub {
Link Here
|
| 1702 |
|
1702 |
|
| 1703 |
$hold = Koha::Holds->find($reserve_id); |
1703 |
$hold = Koha::Holds->find($reserve_id); |
| 1704 |
|
1704 |
|
| 1705 |
is( $hold->expirationdate, '1981-06-10', |
1705 |
is( dt_from_string( $hold->expirationdate )->ymd, '1981-06-10', |
| 1706 |
'Found hold expiration date updated correctly' ); |
1706 |
'Found hold expiration date updated correctly' ); |
| 1707 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
1707 |
is( $hold->priority, '0', 'Found hold priority was not updated' ); |
| 1708 |
|
1708 |
|
|
Lines 1887-1889
subtest 'EmailPatronWhenHoldIsPlaced tests' => sub {
Link Here
|
| 1887 |
|
1887 |
|
| 1888 |
$schema->storage->txn_rollback; |
1888 |
$schema->storage->txn_rollback; |
| 1889 |
}; |
1889 |
}; |
| 1890 |
- |
1890 |
|
|
|
1891 |
subtest 'HourBasedHolds' => sub { |
| 1892 |
plan tests => 4; |
| 1893 |
$schema->storage->txn_begin; |
| 1894 |
|
| 1895 |
my $category = $builder->build({ source => 'Category' }); |
| 1896 |
my $branch = $builder->build({ source => 'Branch' })->{ branchcode }; |
| 1897 |
my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } ); |
| 1898 |
my $itemnumber = $builder->build_sample_item( |
| 1899 |
{ library => $branch, biblionumber => $biblio->biblionumber } ) |
| 1900 |
->itemnumber; |
| 1901 |
|
| 1902 |
my $borrowernumber = Koha::Patron->new( |
| 1903 |
{ |
| 1904 |
firstname => 'firstname', |
| 1905 |
surname => 'surname', |
| 1906 |
categorycode => $category->{categorycode}, |
| 1907 |
branchcode => $branch, |
| 1908 |
} |
| 1909 |
)->store->borrowernumber; |
| 1910 |
|
| 1911 |
t::lib::Mocks::mock_preference('HourBasedHolds', 1); |
| 1912 |
|
| 1913 |
my $reservation_date = DateTime->now->set( hour => 7, minute => 30 ); |
| 1914 |
my $expiration_date = DateTime->now->set( hour => 19, minute => 30 ); |
| 1915 |
|
| 1916 |
my $reserve_id = AddReserve( |
| 1917 |
{ |
| 1918 |
branchcode => $branch, |
| 1919 |
borrowernumber => $borrowernumber, |
| 1920 |
biblionumber => $biblio->biblionumber, |
| 1921 |
priority => |
| 1922 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
| 1923 |
itemnumber => $itemnumber, |
| 1924 |
reservation_date => $reservation_date, |
| 1925 |
expiration_date => $expiration_date, |
| 1926 |
} |
| 1927 |
); |
| 1928 |
|
| 1929 |
my $hold = Koha::Holds->find($reserve_id); |
| 1930 |
is( dt_from_string( $hold->reservedate )->hour, 07, "Hold reserve date is set correctly with hours when HourBasedHolds enabled" ); |
| 1931 |
is( dt_from_string( $hold->expirationdate )->hour, 19, "Hold expiration date is set correctly with hours when HourBasedHolds enabled" ); |
| 1932 |
|
| 1933 |
t::lib::Mocks::mock_preference('HourBasedHolds', 0); |
| 1934 |
|
| 1935 |
$reservation_date = DateTime->now->ymd; |
| 1936 |
$expiration_date = DateTime->now->ymd; |
| 1937 |
|
| 1938 |
$reserve_id = AddReserve( |
| 1939 |
{ |
| 1940 |
branchcode => $branch, |
| 1941 |
borrowernumber => $borrowernumber, |
| 1942 |
biblionumber => $biblio->biblionumber, |
| 1943 |
priority => |
| 1944 |
C4::Reserves::CalculatePriority( $biblio->biblionumber ), |
| 1945 |
itemnumber => $itemnumber, |
| 1946 |
reservation_date => $reservation_date, |
| 1947 |
expiration_date => $expiration_date, |
| 1948 |
} |
| 1949 |
); |
| 1950 |
|
| 1951 |
$hold = Koha::Holds->find($reserve_id); |
| 1952 |
is( dt_from_string( $hold->reservedate )->hour, 00, "Hold reserve date is set correctly when HourBasedHolds disabled" ); |
| 1953 |
is( dt_from_string( $hold->expirationdate )->hour, 23, "Hold expiration date is set correctly when HourBasedHolds disabled" ); |
| 1954 |
|
| 1955 |
$schema->storage->txn_rollback; |
| 1956 |
}; |