View | Details | Raw Unified | Return to bug 30889
Collapse All | Expand All

(-)a/t/db_dependent/Koha/BackgroundJob.t (-2 / +21 lines)
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
};
(-)a/t/lib/Mocks.pm (-2 / +1 lines)
Lines 131-137 sub mock_userenv { Link Here
131
    my $branchcode = $params->{branchcode}     || $userenv->{branchcode}     || 'Branch4T';
131
    my $branchcode = $params->{branchcode}     || $userenv->{branchcode}     || 'Branch4T';
132
    my $branchname   = $params->{branchname}   || $userenv->{branchname};
132
    my $branchname   = $params->{branchname}   || $userenv->{branchname};
133
    my $flags        = $params->{flags}        || $userenv->{flags}          || 0;
133
    my $flags        = $params->{flags}        || $userenv->{flags}          || 0;
134
    my $emailaddress = $params->{emailaddress} || $userenv->{emailaddress};
134
    my $emailaddress = $params->{emailaddress} || $userenv->{email};
135
    my $desk_id       = $params->{desk_id}       || $userenv->{desk_id};
135
    my $desk_id       = $params->{desk_id}       || $userenv->{desk_id};
136
    my $desk_name     = $params->{desk_name}     || $userenv->{desk_name};
136
    my $desk_name     = $params->{desk_name}     || $userenv->{desk_name};
137
    my $register_id   = $params->{register_id}   || $userenv->{register_id};
137
    my $register_id   = $params->{register_id}   || $userenv->{register_id};
138
- 

Return to bug 30889