Lines 5-11
Link Here
|
5 |
|
5 |
|
6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
7 |
use Test::NoWarnings; |
7 |
use Test::NoWarnings; |
8 |
use Test::More tests => 20; |
8 |
use Test::More tests => 21; |
9 |
use Test::Warn; |
9 |
use Test::Warn; |
10 |
|
10 |
|
11 |
use DateTime; |
11 |
use DateTime; |
Lines 223-228
subtest cancel_hold => sub {
Link Here
|
223 |
is( $item->holds->count(), 0, "Item has 0 holds remaining" ); |
223 |
is( $item->holds->count(), 0, "Item has 0 holds remaining" ); |
224 |
}; |
224 |
}; |
225 |
|
225 |
|
|
|
226 |
subtest cancel_waiting_hold => sub { |
227 |
plan tests => 14; |
228 |
|
229 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
230 |
my $patron = $builder->build_object( |
231 |
{ |
232 |
class => 'Koha::Patrons', |
233 |
value => { |
234 |
branchcode => $library->branchcode, |
235 |
} |
236 |
} |
237 |
); |
238 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); |
239 |
t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 0 ); |
240 |
|
241 |
my $item = $builder->build_sample_item( |
242 |
{ |
243 |
library => $library->branchcode, |
244 |
} |
245 |
); |
246 |
|
247 |
Koha::CirculationRules->set_rules( |
248 |
{ |
249 |
categorycode => $patron->categorycode, |
250 |
branchcode => $library->branchcode, |
251 |
itemtype => $item->effective_itemtype, |
252 |
rules => { |
253 |
onshelfholds => 1, |
254 |
reservesallowed => 3, |
255 |
holds_per_record => 3, |
256 |
issuelength => 5, |
257 |
lengthunit => 'days', |
258 |
} |
259 |
} |
260 |
); |
261 |
|
262 |
my $reserve_id = AddReserve( |
263 |
{ |
264 |
branchcode => $library->branchcode, |
265 |
borrowernumber => $patron->borrowernumber, |
266 |
biblionumber => $item->biblio->biblionumber, |
267 |
itemnumber => $item->itemnumber, |
268 |
} |
269 |
); |
270 |
is( $item->biblio->holds->count(), 1, "Hold was placed on bib" ); |
271 |
is( $item->holds->count(), 1, "Hold was placed on specific item" ); |
272 |
|
273 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); |
274 |
my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); |
275 |
my $transaction = C4::SIP::ILS::Transaction::Hold->new(); |
276 |
is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); |
277 |
is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); |
278 |
is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); |
279 |
my $hold = $transaction->drop_hold(); |
280 |
is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" ); |
281 |
is( $item->holds->count(), 0, "Item has 0 holds remaining" ); |
282 |
|
283 |
t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 1 ); |
284 |
|
285 |
$reserve_id = AddReserve( |
286 |
{ |
287 |
branchcode => $library->branchcode, |
288 |
borrowernumber => $patron->borrowernumber, |
289 |
biblionumber => $item->biblio->biblionumber, |
290 |
itemnumber => $item->itemnumber, |
291 |
} |
292 |
); |
293 |
|
294 |
$hold = Koha::Holds->find($reserve_id); |
295 |
ok( $hold, 'Get hold object' ); |
296 |
$hold->update( { found => 'W' } ); |
297 |
$hold->get_from_storage; |
298 |
|
299 |
is( $hold->found, 'W', "Hold was correctly set to waiting." ); |
300 |
|
301 |
$transaction = C4::SIP::ILS::Transaction::Hold->new(); |
302 |
is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); |
303 |
is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); |
304 |
is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); |
305 |
$hold = $transaction->drop_hold(); |
306 |
is( $item->biblio->holds->count(), 1, "Bib has 1 holds remaining" ); |
307 |
is( $item->holds->count(), 1, "Item has 1 holds remaining" ); |
308 |
}; |
309 |
|
226 |
subtest do_hold => sub { |
310 |
subtest do_hold => sub { |
227 |
plan tests => 8; |
311 |
plan tests => 8; |
228 |
|
312 |
|
229 |
- |
|
|