|
Lines 22-30
use Modern::Perl;
Link Here
|
| 22 |
use Test::More tests => 11; |
22 |
use Test::More tests => 11; |
| 23 |
|
23 |
|
| 24 |
use C4::Circulation qw( MarkIssueReturned AddReturn ); |
24 |
use C4::Circulation qw( MarkIssueReturned AddReturn ); |
|
|
25 |
use C4::Reserves qw( AddReserve ); |
| 25 |
use Koha::Checkouts; |
26 |
use Koha::Checkouts; |
| 26 |
use Koha::Database; |
27 |
use Koha::Database; |
| 27 |
use Koha::DateUtils qw( dt_from_string ); |
28 |
use Koha::DateUtils qw( dt_from_string ); |
|
|
29 |
use Koha::Holds; |
| 28 |
|
30 |
|
| 29 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 30 |
use t::lib::Mocks; |
32 |
use t::lib::Mocks; |
|
Lines 296-302
$schema->storage->txn_rollback;
Link Here
|
| 296 |
|
298 |
|
| 297 |
subtest 'automatic_checkin' => sub { |
299 |
subtest 'automatic_checkin' => sub { |
| 298 |
|
300 |
|
| 299 |
plan tests => 9; |
301 |
plan tests => 10; |
| 300 |
|
302 |
|
| 301 |
$schema->storage->txn_begin; |
303 |
$schema->storage->txn_begin; |
| 302 |
|
304 |
|
|
Lines 405-409
subtest 'automatic_checkin' => sub {
Link Here
|
| 405 |
$searched = Koha::Old::Checkouts->find( $checkout_odue_aci->issue_id ); |
407 |
$searched = Koha::Old::Checkouts->find( $checkout_odue_aci->issue_id ); |
| 406 |
is( dt_from_string($searched->returndate), $yesterday, 'old checkout for odue_ac_item has the right return date' ); |
408 |
is( dt_from_string($searched->returndate), $yesterday, 'old checkout for odue_ac_item has the right return date' ); |
| 407 |
|
409 |
|
|
|
410 |
|
| 411 |
subtest 'automatic_checkin AutomaticCheckinAutoFill tests' => sub { |
| 412 |
|
| 413 |
plan tests => 2; |
| 414 |
|
| 415 |
my $checkout_2_ac = Koha::Checkout->new( |
| 416 |
{ |
| 417 |
borrowernumber => $patron->borrowernumber, |
| 418 |
itemnumber => $due_ac_item->itemnumber, |
| 419 |
branchcode => $patron->branchcode, |
| 420 |
date_due => $today |
| 421 |
} |
| 422 |
)->store; |
| 423 |
|
| 424 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $patron->branchcode} } ); |
| 425 |
my $reserveid = AddReserve( |
| 426 |
{ |
| 427 |
branchcode => $patron->branchcode, |
| 428 |
borrowernumber => $patron_2->id, |
| 429 |
biblionumber => $due_ac_item->biblionumber, |
| 430 |
priority => 1 |
| 431 |
} |
| 432 |
); |
| 433 |
|
| 434 |
t::lib::Mocks::mock_preference('AutomaticCheckinAutoFill', '0'); |
| 435 |
|
| 436 |
Koha::Checkouts->automatic_checkin; |
| 437 |
my $reserve = Koha::Holds->find( $reserveid ); |
| 438 |
|
| 439 |
is( $reserve->found, undef, "Hold was not filled when AutomaticCheckinAutoFill disabled"); |
| 440 |
|
| 441 |
my $checkout_3_ac = Koha::Checkout->new( |
| 442 |
{ |
| 443 |
borrowernumber => $patron->borrowernumber, |
| 444 |
itemnumber => $due_ac_item->itemnumber, |
| 445 |
branchcode => $patron->branchcode, |
| 446 |
date_due => $today |
| 447 |
} |
| 448 |
)->store; |
| 449 |
t::lib::Mocks::mock_preference('AutomaticCheckinAutoFill', '1'); |
| 450 |
|
| 451 |
Koha::Checkouts->automatic_checkin; |
| 452 |
$reserve->discard_changes; |
| 453 |
|
| 454 |
is( $reserve->found, 'W', "Hold was filled when AutomaticCheckinAutoFill enabled"); |
| 455 |
}; |
| 456 |
|
| 408 |
$schema->storage->txn_rollback; |
457 |
$schema->storage->txn_rollback; |
| 409 |
} |
458 |
} |
| 410 |
- |
|
|