Lines 4-10
Link Here
|
4 |
# Current state is very rudimentary. Please help to extend it! |
4 |
# Current state is very rudimentary. Please help to extend it! |
5 |
|
5 |
|
6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
7 |
use Test::More tests => 11; |
7 |
use Test::More tests => 12; |
8 |
|
8 |
|
9 |
use Koha::Database; |
9 |
use Koha::Database; |
10 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
Lines 367-372
subtest do_checkin => sub {
Link Here
|
367 |
}; |
367 |
}; |
368 |
}; |
368 |
}; |
369 |
|
369 |
|
|
|
370 |
subtest do_checkout_with_holds => sub { |
371 |
plan tests => 7; |
372 |
|
373 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
374 |
my $patron = $builder->build_object( |
375 |
{ |
376 |
class => 'Koha::Patrons', |
377 |
value => { |
378 |
branchcode => $library->branchcode, |
379 |
} |
380 |
} |
381 |
); |
382 |
my $patron2 = $builder->build_object( |
383 |
{ |
384 |
class => 'Koha::Patrons', |
385 |
value => { |
386 |
branchcode => $library->branchcode, |
387 |
} |
388 |
} |
389 |
); |
390 |
|
391 |
t::lib::Mocks::mock_userenv( |
392 |
{ branchcode => $library->branchcode, flags => 1 } ); |
393 |
|
394 |
my $item = $builder->build_sample_item( |
395 |
{ |
396 |
library => $library->branchcode, |
397 |
} |
398 |
); |
399 |
|
400 |
my $reserve = AddReserve( |
401 |
{ |
402 |
branchcode => $library->branchcode, |
403 |
borrowernumber => $patron2->borrowernumber, |
404 |
biblionumber => $item->biblionumber, |
405 |
} |
406 |
); |
407 |
|
408 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); |
409 |
my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); |
410 |
my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); |
411 |
is( $co_transaction->patron($sip_patron), |
412 |
$sip_patron, "Patron assigned to transaction" ); |
413 |
is( $co_transaction->item($sip_item), |
414 |
$sip_item, "Item assigned to transaction" ); |
415 |
|
416 |
# Test attached holds |
417 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
418 |
my $hold = Koha::Holds->find($reserve); |
419 |
$co_transaction->do_checkout(); |
420 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)'); |
421 |
|
422 |
$hold->set_transfer; |
423 |
$co_transaction->do_checkout(); |
424 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)'); |
425 |
|
426 |
$hold->set_processing; |
427 |
$co_transaction->do_checkout(); |
428 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)'); |
429 |
|
430 |
# Test non-attached holds |
431 |
C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); |
432 |
t::lib::Mocks::mock_preference('AllowItemsOnHoldCheckoutSIP', '0'); |
433 |
$co_transaction->do_checkout(); |
434 |
is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP'); |
435 |
|
436 |
t::lib::Mocks::mock_preference('AllowItemsOnHoldCheckoutSIP', '1'); |
437 |
$co_transaction->do_checkout(); |
438 |
is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP'); |
439 |
}; |
440 |
|
370 |
subtest checkin_lost => sub { |
441 |
subtest checkin_lost => sub { |
371 |
plan tests => 2; |
442 |
plan tests => 2; |
372 |
|
443 |
|
373 |
- |
|
|