Bug 42394: Add regression test for userenv mutation during enqueue
Verifies that BackgroundJob->enqueue() does not mutate the C4::Context userenv hashref as a side-effect. Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
5288847641
commit
5cef972961
|
|
@ -20,14 +20,16 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 15;
|
||||
use Test::More tests => 16;
|
||||
use Test::MockModule;
|
||||
|
||||
use List::MoreUtils qw(any);
|
||||
use Storable qw( dclone );
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::BackgroundJobs;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Koha::Session;
|
||||
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
|
@ -147,3 +149,25 @@ subtest 'search_limited' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'Do not mutate userenv' => sub {
|
||||
plan tests => 1;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } );
|
||||
|
||||
my $session = Koha::Session->get_session();
|
||||
C4::Context->set_userenv_from_session($session);
|
||||
my $pre_userenv = dclone( C4::Context->userenv );
|
||||
my $job_id = t::lib::Koha::BackgroundJob::BatchTest->new->enqueue(
|
||||
{
|
||||
size => $job_size,
|
||||
%$data
|
||||
}
|
||||
);
|
||||
|
||||
my $post_userenv = C4::Context->userenv;
|
||||
is_deeply( $pre_userenv, $post_userenv );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue