MockObject - reference

MockObject - reference

am 25.09.2007 15:03:47 von felippe

Welcome!

I need fake object to tests. I tried to use Test::MockObject

Example below show my problem:
Fake object $tmp was created by fake xxx->new, but ref is still
"Test::MockObject" and set_xxx dies during checking reference

Regards,
Filip (Poland)

use Test::MockObject;
use Data::Dumper;

$Mock_ua = Test::MockObject->new;
$Mock_ua->fake_module('xxx');
$Mock_ua->fake_new('xxx');

my $tmp = xxx->new();
my $mytest = mytest->new();

$mytest->set_xxx($tmp);

package mytest;
{

sub new {
my $class = shift;
my $self = {};
bless ($self, $class);
return $self;
}

sub set_xxx {
my $this = shift;
my $foo = shift;
die "Wrong reference" if (ref $foo ne 'xxx');
}
}