From a82a8e5a4a93dd86a83eed637e33a8e7ae459be1 Mon Sep 17 00:00:00 2001 From: bernhard Date: Wed, 4 Nov 2020 15:57:13 +0100 Subject: [PATCH] Issue #616: use Module::Refresh for unloading the objects --- Kernel/System/UnitTest/Helper.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Kernel/System/UnitTest/Helper.pm b/Kernel/System/UnitTest/Helper.pm index c66253cb96..841601b7c6 100644 --- a/Kernel/System/UnitTest/Helper.pm +++ b/Kernel/System/UnitTest/Helper.pm @@ -25,7 +25,8 @@ use File::Path qw(rmtree); # CPAN modules use Test2::V0; -use DateTime 1.08; # Load DateTime so that we can override functions for the FixedTimeSet(). +use DateTime 1.08; # Load DateTime so that we can override functions for the FixedTimeSet(). +use Module::Refresh; # available in Kernel/cpan-lib # OTOBO modules use Kernel::System::VariableCheck qw(:all); @@ -530,8 +531,10 @@ sub _MockPerlTimeHandling { $FilePath =~ s{::}{/}xmsg; $FilePath .= '.pm'; if ( $INC{$FilePath} ) { - no warnings 'redefine'; ## no critic - delete $INC{$FilePath}; + + # this also unloads the subs, so that we don't get warnings about redefined subs + Module::Refresh->unload_module( $FilePath ); + require $FilePath; ## nofilter(TidyAll::Plugin::OTOBO::Perl::Require) } }