Lines 346-370
subtest 'fill() tests' => sub {
Link Here
|
346 |
|
346 |
|
347 |
subtest 'holds_queue update tests' => sub { |
347 |
subtest 'holds_queue update tests' => sub { |
348 |
|
348 |
|
349 |
plan tests => 1; |
349 |
plan tests => 2; |
350 |
|
350 |
|
351 |
my $biblio = $builder->build_sample_biblio; |
351 |
my $biblio = $builder->build_sample_biblio; |
352 |
|
352 |
|
353 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
353 |
# The check of the pref is in the Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue |
|
|
354 |
# so we mock the base enqueue method here to see if it is called |
355 |
my $mock = Test::MockModule->new('Koha::BackgroundJob'); |
354 |
$mock->mock( |
356 |
$mock->mock( |
355 |
'enqueue', |
357 |
'enqueue', |
356 |
sub { |
358 |
sub { |
357 |
my ( $self, $args ) = @_; |
359 |
my ( $self, $args ) = @_; |
358 |
is_deeply( |
360 |
is_deeply( |
359 |
$args->{biblio_ids}, |
361 |
$args->{job_args}->{biblio_ids}, |
360 |
[ $biblio->id ], |
362 |
[ $biblio->id ], |
361 |
'->fill triggers a holds queue update for the related biblio' |
363 |
'when pref enabled the previous action triggers a holds queue update for the related biblio' |
362 |
); |
364 |
); |
363 |
} |
365 |
} |
364 |
); |
366 |
); |
365 |
|
367 |
|
366 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 ); |
368 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 ); |
367 |
|
369 |
|
|
|
370 |
diag("Filling a hold when pref enabled should trigger a test"); |
368 |
$builder->build_object( |
371 |
$builder->build_object( |
369 |
{ |
372 |
{ |
370 |
class => 'Koha::Holds', |
373 |
class => 'Koha::Holds', |
Lines 376-382
subtest 'fill() tests' => sub {
Link Here
|
376 |
|
379 |
|
377 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); |
380 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); |
378 |
|
381 |
|
379 |
# this call shouldn't add a new test |
382 |
diag("Filling a hold when pref disabled should not trigger a test"); |
380 |
$builder->build_object( |
383 |
$builder->build_object( |
381 |
{ |
384 |
{ |
382 |
class => 'Koha::Holds', |
385 |
class => 'Koha::Holds', |
Lines 385-390
subtest 'fill() tests' => sub {
Link Here
|
385 |
} |
388 |
} |
386 |
} |
389 |
} |
387 |
)->fill; |
390 |
)->fill; |
|
|
391 |
|
392 |
my $library_1 = $builder->build_object( |
393 |
{ |
394 |
class => 'Koha::Libraries', |
395 |
} |
396 |
)->store; |
397 |
my $library_2 = $builder->build_object( |
398 |
{ |
399 |
class => 'Koha::Libraries', |
400 |
} |
401 |
)->store; |
402 |
|
403 |
my $hold = $builder->build_object( |
404 |
{ |
405 |
class => 'Koha::Holds', |
406 |
value => { |
407 |
biblionumber => $biblio->id, |
408 |
branchcode => $library_1->branchcode, |
409 |
} |
410 |
} |
411 |
)->store; |
412 |
|
413 |
# Pref is off, no test triggered |
414 |
diag("Updating a hold location when pref disabled should not trigger a test"); |
415 |
$hold->branchcode( $library_2->branchcode )->store; |
416 |
|
417 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 ); |
418 |
diag("Updating a hold location when pref enabled should trigger a test"); |
419 |
|
420 |
# Pref is on, test triggered |
421 |
$hold->branchcode( $library_1->branchcode )->store; |
422 |
|
423 |
diag("Update with no change to pickup location should not trigger a test"); |
424 |
$hold->branchcode( $library_1->branchcode )->store; |
425 |
|
388 |
}; |
426 |
}; |
389 |
|
427 |
|
390 |
$schema->storage->txn_rollback; |
428 |
$schema->storage->txn_rollback; |
391 |
- |
|
|