Given the following Role:
package MyRole;
use Moo::Role;
sub foo {
return 'blah';
}
And the following consuming class:
package MyClass;
use Moo;
with 'MyRole';
around foo {
my ($self, $orig) = @_;
return 'bak' if $self->$orig eq 'baz';
return $self->$orig;
}
I would like to test behaviour defined in the around modifier. How do I do this? It seems that Test::MockModule won't work:
use MyClass;
use Test::Most;
use Test::MockModule;
my $mock = Test::MockModule->new('MyRole');
$mock->mock('foo' => sub { return 'baz' });
my $obj = MyClass->new;
# Does not work
is $obj->foo, 'bak', 'Foo is what it oughtta be';
Aucun commentaire:
Enregistrer un commentaire