|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 5; |
22 |
use Test::More tests => 6; |
| 23 |
|
23 |
|
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
|
Lines 38-44
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 38 |
|
38 |
|
| 39 |
subtest 'fill() tests' => sub { |
39 |
subtest 'fill() tests' => sub { |
| 40 |
|
40 |
|
| 41 |
plan tests => 12; |
41 |
plan tests => 13; |
| 42 |
|
42 |
|
| 43 |
$schema->storage->txn_begin; |
43 |
$schema->storage->txn_begin; |
| 44 |
|
44 |
|
|
Lines 233-238
subtest 'fill() tests' => sub {
Link Here
|
| 233 |
); |
233 |
); |
| 234 |
}; |
234 |
}; |
| 235 |
|
235 |
|
|
|
236 |
subtest 'holds_queue update tests' => sub { |
| 237 |
|
| 238 |
plan tests => 1; |
| 239 |
|
| 240 |
my $biblio = $builder->build_sample_biblio; |
| 241 |
|
| 242 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
| 243 |
$mock->mock( 'enqueue', sub { |
| 244 |
my ( $self, $args ) = @_; |
| 245 |
is_deeply( |
| 246 |
$args->{biblio_ids}, |
| 247 |
[ $biblio->id ], |
| 248 |
'->fill triggers a holds queue update for the related biblio' |
| 249 |
); |
| 250 |
} ); |
| 251 |
|
| 252 |
$builder->build_object( |
| 253 |
{ |
| 254 |
class => 'Koha::Holds', |
| 255 |
value => { |
| 256 |
biblionumber => $biblio->id, |
| 257 |
} |
| 258 |
} |
| 259 |
)->fill; |
| 260 |
}; |
| 261 |
|
| 236 |
$schema->storage->txn_rollback; |
262 |
$schema->storage->txn_rollback; |
| 237 |
}; |
263 |
}; |
| 238 |
|
264 |
|
|
Lines 456-462
subtest 'is_pickup_location_valid() tests' => sub {
Link Here
|
| 456 |
|
482 |
|
| 457 |
subtest 'cancel() tests' => sub { |
483 |
subtest 'cancel() tests' => sub { |
| 458 |
|
484 |
|
| 459 |
plan tests => 5; |
485 |
plan tests => 6; |
| 460 |
|
486 |
|
| 461 |
$schema->storage->txn_begin; |
487 |
$schema->storage->txn_begin; |
| 462 |
|
488 |
|
|
Lines 526-530
subtest 'cancel() tests' => sub {
Link Here
|
| 526 |
'Patron link is set to the configured anonymous patron immediately' |
552 |
'Patron link is set to the configured anonymous patron immediately' |
| 527 |
); |
553 |
); |
| 528 |
|
554 |
|
|
|
555 |
subtest 'holds_queue update tests' => sub { |
| 556 |
|
| 557 |
plan tests => 1; |
| 558 |
|
| 559 |
my $biblio = $builder->build_sample_biblio; |
| 560 |
|
| 561 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
| 562 |
$mock->mock( 'enqueue', sub { |
| 563 |
my ( $self, $args ) = @_; |
| 564 |
is_deeply( |
| 565 |
$args->{biblio_ids}, |
| 566 |
[ $biblio->id ], |
| 567 |
'->cancel triggers a holds queue update for the related biblio' |
| 568 |
); |
| 569 |
} ); |
| 570 |
|
| 571 |
$builder->build_object( |
| 572 |
{ |
| 573 |
class => 'Koha::Holds', |
| 574 |
value => { |
| 575 |
biblionumber => $biblio->id, |
| 576 |
} |
| 577 |
} |
| 578 |
)->cancel; |
| 579 |
}; |
| 580 |
|
| 581 |
$schema->storage->txn_rollback; |
| 582 |
}; |
| 583 |
|
| 584 |
subtest 'suspend_hold() and resume() tests' => sub { |
| 585 |
|
| 586 |
plan tests => 2; |
| 587 |
|
| 588 |
$schema->storage->txn_begin; |
| 589 |
|
| 590 |
my $biblio = $builder->build_sample_biblio; |
| 591 |
my $action; |
| 592 |
|
| 593 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
| 594 |
$mock->mock( 'enqueue', sub { |
| 595 |
my ( $self, $args ) = @_; |
| 596 |
is_deeply( |
| 597 |
$args->{biblio_ids}, |
| 598 |
[ $biblio->id ], |
| 599 |
"->$action triggers a holds queue update for the related biblio" |
| 600 |
); |
| 601 |
} ); |
| 602 |
|
| 603 |
my $hold = $builder->build_object( |
| 604 |
{ |
| 605 |
class => 'Koha::Holds', |
| 606 |
value => { |
| 607 |
biblionumber => $biblio->id, |
| 608 |
} |
| 609 |
} |
| 610 |
); |
| 611 |
|
| 612 |
$action = 'suspend_hold'; |
| 613 |
$hold->suspend_hold; |
| 614 |
|
| 615 |
$action = 'resume'; |
| 616 |
$hold->resume; |
| 617 |
|
| 529 |
$schema->storage->txn_rollback; |
618 |
$schema->storage->txn_rollback; |
| 530 |
}; |
619 |
}; |