Lines 65-71
subtest '_derived_class() tests' => sub {
Link Here
|
65 |
|
65 |
|
66 |
subtest 'enqueue() tests' => sub { |
66 |
subtest 'enqueue() tests' => sub { |
67 |
|
67 |
|
68 |
plan tests => 6; |
68 |
plan tests => 7; |
69 |
|
69 |
|
70 |
$schema->storage->txn_begin; |
70 |
$schema->storage->txn_begin; |
71 |
|
71 |
|
Lines 77-91
subtest 'enqueue() tests' => sub {
Link Here
|
77 |
is( $job->status, 'new', 'Initial status set correctly' ); |
77 |
is( $job->status, 'new', 'Initial status set correctly' ); |
78 |
is( $job->borrowernumber, undef, 'No userenv, borrowernumber undef' ); |
78 |
is( $job->borrowernumber, undef, 'No userenv, borrowernumber undef' ); |
79 |
|
79 |
|
|
|
80 |
my $interface = C4::Context->interface; |
80 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
81 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
81 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
82 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
|
|
83 |
my $job_context = { |
84 |
number => $patron->borrowernumber, |
85 |
id => $patron->userid, |
86 |
cardnumber => $patron->cardnumber, |
87 |
firstname => $patron->firstname, |
88 |
surname => $patron->surname, |
89 |
branch => $patron->library->branchcode, |
90 |
branchname => $patron->library->branchname, |
91 |
flags => $patron->flags, |
92 |
emailaddress => $patron->email, |
93 |
register_id => undef, |
94 |
register_name => undef, |
95 |
shibboleth => undef, |
96 |
desk_id => undef, |
97 |
desk_name => undef, |
98 |
interface => $interface |
99 |
}; |
82 |
|
100 |
|
83 |
$job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2, 3 ] } ); |
101 |
$job_id = Koha::BackgroundJob::BatchUpdateItem->new->enqueue( { record_ids => [ 1, 2, 3 ] } ); |
84 |
$job = Koha::BackgroundJobs->find($job_id)->_derived_class; |
102 |
$job = Koha::BackgroundJobs->find($job_id)->_derived_class; |
85 |
|
103 |
|
86 |
is( $job->size, 3, 'Three steps' ); |
104 |
is( $job->size, 3, 'Three steps' ); |
87 |
is( $job->status, 'new', 'Initial status set correctly' ); |
105 |
is( $job->status, 'new', 'Initial status set correctly' ); |
88 |
is( $job->borrowernumber, $patron->id, 'No userenv, borrowernumber undef' ); |
106 |
is( $job->borrowernumber, $patron->id, 'Borrowernumber set from userenv' ); |
|
|
107 |
is_deeply( decode_json( $job->context ), $job_context, 'Context set from userenv + interface' ); |
89 |
|
108 |
|
90 |
$schema->storage->txn_rollback; |
109 |
$schema->storage->txn_rollback; |
91 |
}; |
110 |
}; |