|
Lines 145-166
ModReserve({
Link Here
|
| 145 |
suspend_until => output_pref( { dt => dt_from_string( "2013-01-01", "iso" ), dateonly => 1 } ), |
145 |
suspend_until => output_pref( { dt => dt_from_string( "2013-01-01", "iso" ), dateonly => 1 } ), |
| 146 |
}); |
146 |
}); |
| 147 |
|
147 |
|
| 148 |
my $reserve = GetReserve( $reserve_id ); |
148 |
$hold = Koha::Holds->find( $reserve_id ); |
| 149 |
ok( $reserve->{'priority'} eq '4', "Test GetReserve(), priority changed correctly" ); |
149 |
ok( $hold->priority eq '4', "Test ModReserve, priority changed correctly" ); |
| 150 |
ok( $reserve->{'suspend'}, "Test GetReserve(), suspend hold" ); |
150 |
ok( $hold->suspend, "Test ModReserve, suspend hold" ); |
| 151 |
is( $reserve->{'suspend_until'}, '2013-01-01 00:00:00', "Test GetReserve(), suspend until date" ); |
151 |
is( $hold->suspend_until, '2013-01-01 00:00:00', "Test ModReserve, suspend until date" ); |
| 152 |
|
152 |
|
| 153 |
ToggleSuspend( $reserve_id ); |
153 |
ToggleSuspend( $reserve_id ); |
| 154 |
$reserve = GetReserve( $reserve_id ); |
154 |
$hold = Koha::Holds->find( $reserve_id ); |
| 155 |
ok( !$reserve->{'suspend'}, "Test ToggleSuspend(), no date" ); |
155 |
ok( ! $hold->suspend, "Test ToggleSuspend(), no date" ); |
| 156 |
|
156 |
|
| 157 |
ToggleSuspend( $reserve_id, '2012-01-01' ); |
157 |
ToggleSuspend( $reserve_id, '2012-01-01' ); |
| 158 |
$reserve = GetReserve( $reserve_id ); |
158 |
$hold = Koha::Holds->find( $reserve_id ); |
| 159 |
is( $reserve->{'suspend_until'}, '2012-01-01 00:00:00', "Test ToggleSuspend(), with date" ); |
159 |
is( $hold->suspend_until, '2012-01-01 00:00:00', "Test ToggleSuspend(), with date" ); |
| 160 |
|
160 |
|
| 161 |
AutoUnsuspendReserves(); |
161 |
AutoUnsuspendReserves(); |
| 162 |
$reserve = GetReserve( $reserve_id ); |
162 |
$hold = Koha::Holds->find( $reserve_id ); |
| 163 |
ok( !$reserve->{'suspend'}, "Test AutoUnsuspendReserves()" ); |
163 |
ok( ! $hold->suspend, "Test AutoUnsuspendReserves()" ); |
| 164 |
|
164 |
|
| 165 |
SuspendAll( |
165 |
SuspendAll( |
| 166 |
borrowernumber => $borrowernumber, |
166 |
borrowernumber => $borrowernumber, |
|
Lines 168-185
SuspendAll(
Link Here
|
| 168 |
suspend => 1, |
168 |
suspend => 1, |
| 169 |
suspend_until => '2012-01-01', |
169 |
suspend_until => '2012-01-01', |
| 170 |
); |
170 |
); |
| 171 |
$reserve = GetReserve( $reserve_id ); |
171 |
$hold = Koha::Holds->find( $reserve_id ); |
| 172 |
is( $reserve->{'suspend'}, 1, "Test SuspendAll()" ); |
172 |
is( $hold->suspend, 1, "Test SuspendAll()" ); |
| 173 |
is( $reserve->{'suspend_until'}, '2012-01-01 00:00:00', "Test SuspendAll(), with date" ); |
173 |
is( $hold->suspend_until, '2012-01-01 00:00:00', "Test SuspendAll(), with date" ); |
| 174 |
|
174 |
|
| 175 |
SuspendAll( |
175 |
SuspendAll( |
| 176 |
borrowernumber => $borrowernumber, |
176 |
borrowernumber => $borrowernumber, |
| 177 |
biblionumber => $biblionumber, |
177 |
biblionumber => $biblionumber, |
| 178 |
suspend => 0, |
178 |
suspend => 0, |
| 179 |
); |
179 |
); |
| 180 |
$reserve = GetReserve( $reserve_id ); |
180 |
$hold = Koha::Holds->find( $reserve_id ); |
| 181 |
is( $reserve->{'suspend'}, 0, "Test resuming with SuspendAll()" ); |
181 |
is( $hold->suspend, 0, "Test resuming with SuspendAll()" ); |
| 182 |
is( $reserve->{'suspend_until'}, undef, "Test resuming with SuspendAll(), should have no suspend until date" ); |
182 |
is( $hold->suspend_until, undef, "Test resuming with SuspendAll(), should have no suspend until date" ); |
| 183 |
|
183 |
|
| 184 |
# Add a new hold for the borrower whose hold we canceled earlier, this time at the bib level |
184 |
# Add a new hold for the borrower whose hold we canceled earlier, this time at the bib level |
| 185 |
AddReserve( |
185 |
AddReserve( |
|
Lines 204-230
my $reserveid = C4::Reserves::GetReserveId(
Link Here
|
| 204 |
} |
204 |
} |
| 205 |
); |
205 |
); |
| 206 |
is( $reserveid, $holds->next->reserve_id, "Test GetReserveId" ); |
206 |
is( $reserveid, $holds->next->reserve_id, "Test GetReserveId" ); |
| 207 |
ModReserveMinusPriority( $itemnumber, $reserve->{'reserve_id'} ); |
207 |
ModReserveMinusPriority( $itemnumber, $reserveid ); |
| 208 |
$holds = $patron->holds; |
208 |
$holds = $patron->holds; |
| 209 |
is( $holds->next->itemnumber, $itemnumber, "Test ModReserveMinusPriority()" ); |
209 |
is( $holds->next->itemnumber, $itemnumber, "Test ModReserveMinusPriority()" ); |
| 210 |
|
210 |
|
| 211 |
$holds = $biblio->holds; |
211 |
$holds = $biblio->holds; |
| 212 |
$hold = $holds->next; |
212 |
$hold = $holds->next; |
| 213 |
AlterPriority( 'top', $hold->reserve_id ); |
213 |
AlterPriority( 'top', $hold->reserve_id ); |
| 214 |
$reserve = GetReserve( $reserve->{'reserve_id'} ); |
214 |
$hold = Koha::Holds->find( $reserveid ); |
| 215 |
is( $reserve->{'priority'}, '1', "Test AlterPriority(), move to top" ); |
215 |
is( $hold->priority, '1', "Test AlterPriority(), move to top" ); |
| 216 |
|
216 |
|
| 217 |
AlterPriority( 'down', $reserve->{'reserve_id'} ); |
217 |
AlterPriority( 'down', $hold->reserve_id ); |
| 218 |
$reserve = GetReserve( $reserve->{'reserve_id'} ); |
218 |
$hold = Koha::Holds->find( $reserveid ); |
| 219 |
is( $reserve->{'priority'}, '2', "Test AlterPriority(), move down" ); |
219 |
is( $hold->priority, '2', "Test AlterPriority(), move down" ); |
| 220 |
|
220 |
|
| 221 |
AlterPriority( 'up', $reserve->{'reserve_id'} ); |
221 |
AlterPriority( 'up', $hold->reserve_id ); |
| 222 |
$reserve = GetReserve( $reserve->{'reserve_id'} ); |
222 |
$hold = Koha::Holds->find( $reserveid ); |
| 223 |
is( $reserve->{'priority'}, '1', "Test AlterPriority(), move up" ); |
223 |
is( $hold->priority, '1', "Test AlterPriority(), move up" ); |
| 224 |
|
224 |
|
| 225 |
AlterPriority( 'bottom', $reserve->{'reserve_id'} ); |
225 |
AlterPriority( 'bottom', $hold->reserve_id ); |
| 226 |
$reserve = GetReserve( $reserve->{'reserve_id'} ); |
226 |
$hold = Koha::Holds->find( $reserveid ); |
| 227 |
is( $reserve->{'priority'}, '5', "Test AlterPriority(), move to bottom" ); |
227 |
is( $hold->priority, '5', "Test AlterPriority(), move to bottom" ); |
| 228 |
|
228 |
|
| 229 |
# Regression test for bug 2394 |
229 |
# Regression test for bug 2394 |
| 230 |
# |
230 |
# |
|
Lines 315-322
my $reserveid2 = C4::Reserves::GetReserveId(
Link Here
|
| 315 |
|
315 |
|
| 316 |
CancelReserve({ reserve_id => $reserveid1 }); |
316 |
CancelReserve({ reserve_id => $reserveid1 }); |
| 317 |
|
317 |
|
| 318 |
my $reserve2 = GetReserve( $reserveid2 ); |
318 |
my $hold2 = Koha::Holds->find( $reserveid2 ); |
| 319 |
is( $reserve2->{priority}, 1, "After cancelreserve, the 2nd reserve becomes the first on the waiting list" ); |
319 |
is( $hold2->priority, 1, "After cancelreserve, the 2nd reserve becomes the first on the waiting list" ); |
| 320 |
|
320 |
|
| 321 |
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum); |
321 |
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum); |
| 322 |
AddReserve( |
322 |
AddReserve( |
|
Lines 333-344
my $reserveid3 = C4::Reserves::GetReserveId(
Link Here
|
| 333 |
} |
333 |
} |
| 334 |
); |
334 |
); |
| 335 |
|
335 |
|
| 336 |
my $reserve3 = GetReserve( $reserveid3 ); |
336 |
my $hold3 = Koha::Holds->find( $reserveid3 ); |
| 337 |
is( $reserve3->{priority}, 2, "New reserve for patron 0, the reserve has a priority = 2" ); |
337 |
is( $hold3->priority, 2, "New reserve for patron 0, the reserve has a priority = 2" ); |
| 338 |
|
338 |
|
| 339 |
ModReserve({ reserve_id => $reserveid2, rank => 'del' }); |
339 |
ModReserve({ reserve_id => $reserveid2, rank => 'del' }); |
| 340 |
$reserve3 = GetReserve( $reserveid3 ); |
340 |
$hold3 = Koha::Holds->find( $reserveid3 ); |
| 341 |
is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
341 |
is( $hold3->priority, 1, "After ModReserve, the 3rd reserve becomes the first on the waiting list" ); |
| 342 |
|
342 |
|
| 343 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
343 |
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber); |
| 344 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |
344 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 ); |