Bug 35536: Reorder rollbacks

Time to move all RemovePlugins calls BEFORE rollbacks.
Broken.t did not even include a transaction! Some modules
are removed there as well.

Test plan:
Search for wrong order with:
  grep -Pzo "txn_rollback;\n.*RemovePlugins" $(git grep -l RemovePlugins)
  No occurrences left? Think of another grep :)
Check number of records in plugin_data/methods.
Repeat: prove $(git grep -l Koha::Plugin | grep -P "^t\/db")
And check number of records again. Same?

Bonus: Apply TestMR plugin patch (marked DO NOT PUSH).
Run perl -MKoha::Plugins -e"Koha::Plugins->new->InstallPlugins".
Check plugin records in database.
Keep those records but remove last patch from git.
Run previous prove and verify no data changes since last check.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit e32174f29a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Marcel de Rooy 2023-12-14 07:54:22 +00:00 committed by Fridolin Somers
parent 62f2574732
commit f11c05bbdd
7 changed files with 19 additions and 21 deletions

View File

@ -84,6 +84,6 @@ subtest 'background_tasks() hooks tests' => sub {
is_deeply( $tasks, $bj->core_types_to_classes, 'Only core mapping returned when plugins disabled' );
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};

View File

@ -99,6 +99,6 @@ subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' =>
qr/Plugin error \(Test Plugin\): Exception 'Koha::Exception' thrown 'item_barcode_transform called with parameter: THISISATEST'/,
'Koha::Item->store calls the item_barcode_transform hook';
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};

View File

@ -83,6 +83,6 @@ subtest 'after_biblio_action() and after_item_action() hooks tests' => sub {
qr/after_biblio_action called with action: delete, id: $biblio_id/,
'DelBiblio calls the hook with action=delete biblio_id passed';
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};

View File

@ -15,15 +15,13 @@
# with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 3;
use Test::MockModule;
use File::Basename;
use Test::More tests => 2;
use Test::Warn;
use File::Basename;
use t::lib::Mocks;
use t::lib::TestBuilder;
use Koha::Database;
BEGIN {
# Mock pluginsdir before loading Plugins module
@ -31,17 +29,19 @@ BEGIN {
t::lib::Mocks::mock_config( 'pluginsdir', $path );
use_ok('Koha::Plugins');
use_ok('Koha::Plugins::Handler');
}
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
t::lib::Mocks::mock_config( 'enable_plugins', 1 );
my $plugins = Koha::Plugins->new;
warnings_are
{ $plugins->InstallPlugins; }
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ];
warnings_are { $plugins->InstallPlugins; }
[
"Calling 'install' died for plugin Koha::Plugin::BrokenInstall",
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade"
];
$schema->storage->txn_begin;

View File

@ -120,6 +120,6 @@ subtest 'after_circ_action() hook tests' => sub {
'AddReturn calls the after_circ_action hook';
};
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};

View File

@ -87,8 +87,6 @@ subtest 'check_password hook tests' => sub {
ok( $patron->set_password({ password => '4321' }), 'Patron password updated with good string' );
ok( $patron->set_password({ password => 'explosion', skip_validation => 1}), 'Patron password updated via skip validation');
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};
1;

View File

@ -65,6 +65,6 @@ subtest 'after_authority_action hook' => sub {
qr/after_authority_action called with action: delete, id: $id/,
'DelAuthority calls the hook with action=delete, id passed';
$schema->storage->txn_rollback;
Koha::Plugins->RemovePlugins;
$schema->storage->txn_rollback;
};