@@ -, +, @@ --- t/db_dependent/Koha/BackgroundJob.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) --- a/t/db_dependent/Koha/BackgroundJob.t +++ a/t/db_dependent/Koha/BackgroundJob.t @@ -38,7 +38,9 @@ my $builder = t::lib::TestBuilder->new; subtest '_derived_class() tests' => sub { - plan tests => 3; + plan tests => 6; + + t::lib::Mocks::mock_config( 'enable_plugins', 0 ); $schema->storage->txn_begin; @@ -64,6 +66,30 @@ subtest '_derived_class() tests' => sub { is_deeply( $job->unblessed, $derived->unblessed, '_derived_class object refers to the same DB object and can be manipulated as expected' ); + t::lib::Mocks::mock_config( 'enable_plugins', 1 ); + + $job_object = Koha::BackgroundJob->new(); + $mapping = $job_object->type_to_class_mapping; + + # pick the first + $type = ( keys %{$mapping} )[0]; + + $job = $builder->build_object( + { class => 'Koha::BackgroundJobs', + value => { type => $type, data => 'Foo' } + } + ); + + $derived = $job->_derived_class; + + is( ref($derived), $mapping->{$type}, 'Job object class is correct' ); + ok( $derived->in_storage, 'The object is correctly marked as in storage' ); + + $derived->data('Bar')->store->discard_changes; + $job->discard_changes; + + is_deeply( $job->unblessed, $derived->unblessed, '_derived_class object refers to the same DB object and can be manipulated as expected' ); + $schema->storage->txn_rollback; }; --