Test::Mock::Class::Role::Meta::Class - Metaclass for mock class
This role provides an API for defining and changing behavior of mock class.
Base object role for mock class. The default is Test::Mock::Class::Role::Object.
Regexp matches method names which are not created automatically for mock class.
Regexp matches method names which are constructors rather than normal methods.
Creates new Moose::Meta::Class object which represents named mock class. It automatically adds all methods which exists in original class, except those which matches mock_ignore_methods_regexp attribute.
mock_ignore_methods_regexp
If new method exists in original class, it is created as constructor.
new
The method takes additional arguments:
Optional class parameter is a name of original class and its methods will be created for new mock class.
List of additional methods to create.
The constructor returns metaclass object.
Test::Mock::Class->create_mock_class( 'IO::File::Mock' => ( class => 'IO::File' ) );
Creates new Moose::Meta::Class object which represents anonymous mock class. Optional class parameter is a name of original class and its methods will be created for new mock class.
Anonymous classes are destroyed once the metaclass they are attached to goes out of scope.
my $meta = Test::Mock::Class->create_mock_anon_class( class => 'File::Temp' );
Adds new method to mock class. The behavior of this method can be changed with mock_return and other methods.
mock_return
Adds new constructor to mock class. This is almost the same as add_mock_method but it returns new object rather than defined value.
add_mock_method
The calls counter is set to 1 for new object's constructor.
1
Constructs mock class based on original class. Adds the same methods as in original class. If original class has new method, the constructor with this name is created.
Test::Mock::Class.
The API is not stable yet and can be changed in future.
Piotr Roszatycki <dexter@cpan.org>
Based on SimpleTest, an open source unit test framework for the PHP programming language, created by Marcus Baker, Jason Sweat, Travis Swicegood, Perrick Penet and Edward Z. Yang.
Copyright (c) 2009, 2010 Piotr Roszatycki <dexter@cpan.org>.
This program is free software; you can redistribute it and/or modify it under GNU Lesser General Public License.
To install Test::Mock::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mock::Class
CPAN shell
perl -MCPAN -e shell install Test::Mock::Class
For more information on module installation, please visit the detailed CPAN module installation guide.