|
Lines 17-27
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
| 21 |
|
21 |
|
| 22 |
use Koha::Database; |
22 |
use Koha::Database; |
| 23 |
use Koha::BackgroundJobs; |
23 |
use Koha::BackgroundJobs; |
|
|
24 |
use Koha::BackgroundJob::BatchUpdateItem; |
| 24 |
|
25 |
|
|
|
26 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
| 26 |
|
28 |
|
| 27 |
my $schema = Koha::Database->new->schema; |
29 |
my $schema = Koha::Database->new->schema; |
|
Lines 56-58
subtest '_derived_class() tests' => sub {
Link Here
|
| 56 |
|
58 |
|
| 57 |
$schema->storage->txn_rollback; |
59 |
$schema->storage->txn_rollback; |
| 58 |
}; |
60 |
}; |
| 59 |
- |
61 |
|
|
|
62 |
subtest 'enqueue() tests' => sub { |
| 63 |
|
| 64 |
plan tests => 6; |
| 65 |
|
| 66 |
$schema->storage->txn_begin; |
| 67 |
|
| 68 |
# FIXME: This all feels we need to do it better... |
| 69 |
my $job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2 ] } ); |
| 70 |
my $job = Koha::BackgroundJobs->find($job_id)->_derived_class; |
| 71 |
|
| 72 |
is( $job->size, 2, 'Two steps' ); |
| 73 |
is( $job->status, 'new', 'Initial status set correctly' ); |
| 74 |
is( $job->borrowernumber, undef, 'No userenv, borrowernumber undef' ); |
| 75 |
|
| 76 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 77 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
| 78 |
|
| 79 |
$job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2, 3 ] } ); |
| 80 |
$job = Koha::BackgroundJobs->find($job_id)->_derived_class; |
| 81 |
|
| 82 |
is( $job->size, 3, 'Three steps' ); |
| 83 |
is( $job->status, 'new', 'Initial status set correctly' ); |
| 84 |
is( $job->borrowernumber, $patron->id, 'No userenv, borrowernumber undef' ); |
| 85 |
|
| 86 |
$schema->storage->txn_rollback; |
| 87 |
}; |