The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Magpie::Mock - A mock object

DESCRIPTION

Mock objects are the objects you pass around as if they were real objects. They do not have a defined API; any method call is valid. A mock on its own is in record mode - method calls and arguments will be saved. You can switch temporarily to stub and verification mode with when and verify in Test::Magpie, respectively.

ATTRIBUTES

class

This attribute is the name of the class that the object is pretending to be blessed into. This is only needed if you call ref() on the object and want it to return a particular type.

stubs

This attribute is internal, and not publically accessible.

Returns a map of method name to stub array references. Stubs are matched against invocation arguments to determine which stub to dispatch to.

invocations

This attribute is internal, and not publically accessible.

Returns an array reference of all method invocations on this mock.

METHODS

isa $class

Forced to return true for any package

does $role

Forced to return true for any role

ref

Returns the value of the object's class attribute. This also works if you call ref() as a function instead of a method.

AUTHOR

Oliver Charles

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Oliver Charles <oliver.g.charles@googlemail.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.