lHelper
l
lsub mock_module {
l my ($module,$options,@functions) =
@_;
l
l my $no_auto =
defined($options->{no_auto}) ? $options->{no_auto} : 1;
l my $create_new =
defined($options->{create_new}) ? $options->{create_new} : 1;
l my $testmockmodule = new
Test::MockModule($module, no_auto => $no_auto);
l
l my $object;
l if ($create_new) {
l $object = bless {}, $module;
l $testmockmodule->mock('new',sub
{ $logger->log($module,'new',@_); return $object });
l }
l
l for my $function (@functions) {
l
$testmockmodule->mock($function,sub {
$logger->log($module,$function,@_) });
l }
l
l no strict 'refs';
l push @{$module .
"::ISA"},'Exporter';
l
l my $module_path = $module;
l $module_path =~ s{::}{/}xmsg;
l $module_path .= '.pm';
l $INC{$module_path} = "1 (Inserted
by mock_module())";
l
l return $testmockmodule, $object;
l}