Skip to content

Commit

Permalink
Issue #616: use Module::Refresh for unloading the objects
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Nov 4, 2020
1 parent 4a6e133 commit a82a8e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Kernel/System/UnitTest/Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit a82a8e5

Please sign in to comment.