From 4f064f13d7cee7ec163581f8e880a902c643d376 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 26 Jul 2022 09:54:35 -0300 Subject: [PATCH] Bug 31223: Regression tests This patch adds tests so we are sure things don't explode with/without plugins enabled. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/BackgroundJob.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/BackgroundJob.t b/t/db_dependent/Koha/BackgroundJob.t index 2c368383f56..8ebcec9e8d5 100755 --- a/t/db_dependent/Koha/BackgroundJob.t +++ b/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; }; -- 2.34.1