Lines 41-48
my $net_stomp = Test::MockModule->new('Net::Stomp');
Link Here
|
41 |
$net_stomp->mock( 'send_with_receipt', sub { return 1 } ); |
41 |
$net_stomp->mock( 'send_with_receipt', sub { return 1 } ); |
42 |
|
42 |
|
43 |
my $background_job_module = Test::MockModule->new('Koha::BackgroundJob'); |
43 |
my $background_job_module = Test::MockModule->new('Koha::BackgroundJob'); |
44 |
$background_job_module->mock( '_derived_class', |
44 |
$background_job_module->mock( |
45 |
sub { t::lib::Koha::BackgroundJob::BatchTest->new } ); |
45 |
'type_to_class_mapping', |
|
|
46 |
sub { |
47 |
return { batch_test => 't::lib::Koha::BackgroundJob::BatchTest' }; |
48 |
} |
49 |
); |
46 |
|
50 |
|
47 |
my $data = { a => 'aaa', b => 'bbb' }; |
51 |
my $data = { a => 'aaa', b => 'bbb' }; |
48 |
my $job_size = 10; |
52 |
my $job_size = 10; |
Lines 64-81
is( $new_job->size, $job_size, 'job size retrieved correctly' );
Link Here
|
64 |
is( $new_job->status, "new", 'job has not started yet, status is new' ); |
68 |
is( $new_job->status, "new", 'job has not started yet, status is new' ); |
65 |
is( $new_job->type, "batch_test", 'job type retrieved from ->job_type' ); |
69 |
is( $new_job->type, "batch_test", 'job type retrieved from ->job_type' ); |
66 |
|
70 |
|
|
|
71 |
# FIXME: This behavior doesn't seem correct. It shouldn't be the background job's |
72 |
# responsibility to return 'undef'. Some higher-level check should raise a |
73 |
# proper exception. |
67 |
# Test cancelled job |
74 |
# Test cancelled job |
68 |
$new_job->status('cancelled')->store; |
75 |
$new_job->status('cancelled')->store; |
69 |
my $processed_job = |
76 |
my $processed_job = $new_job->process; |
70 |
t::lib::Koha::BackgroundJob::BatchTest->process( { job_id => $new_job->id } ); |
|
|
71 |
is( $processed_job, undef ); |
77 |
is( $processed_job, undef ); |
72 |
$new_job->discard_changes; |
78 |
$new_job->discard_changes; |
73 |
is( $new_job->status, "cancelled", "A cancelled job has not been processed" ); |
79 |
is( $new_job->status, "cancelled", "A cancelled job has not been processed" ); |
74 |
|
80 |
|
75 |
# Test new job to process |
81 |
# Test new job to process |
76 |
$new_job->status('new')->store; |
82 |
$new_job->status('new')->store; |
77 |
$new_job = |
83 |
$new_job = $new_job->process; |
78 |
t::lib::Koha::BackgroundJob::BatchTest->process( { job_id => $new_job->id } ); |
|
|
79 |
is( $new_job->status, "finished", 'job is new finished!' ); |
84 |
is( $new_job->status, "finished", 'job is new finished!' ); |
80 |
is( scalar( @{ $new_job->messages } ), 10, '10 messages generated' ); |
85 |
is( scalar( @{ $new_job->messages } ), 10, '10 messages generated' ); |
81 |
is_deeply( |
86 |
is_deeply( |