1Mock::Quick::Object(3)User Contributed Perl DocumentationMock::Quick::Object(3)
2
3
4
6 Mock::Quick::Object - Object mocking for Mock::Quick
7
9 Provides object mocking. See Mock::Quick for a better interface.
10
12 use Mock::Quick::Object;
13 use Mock::Quick::Method;
14
15 my $obj = Mock::Quick::Object->new(
16 foo => 'bar', # define attribute
17 do_it => qmeth { ... }, # define method
18 ...
19 );
20
21 is( $obj->foo, 'bar' );
22 $obj->foo( 'baz' );
23 is( $obj->foo, 'baz' );
24
25 $obj->do_it();
26
27 # define the new attribute automatically
28 $obj->bar( 'xxx' );
29
30 # define a new method on the fly
31 $obj->baz( Mock::Quick::Method->new( sub { ... });
32
33 # remove an attribute or method
34 $obj->baz( \$Mock::Quick::Util::CLEAR );
35
37 Chad Granum exodist7@gmail.com
38
40 Copyright (C) 2011 Chad Granum
41
42 Mock-Quick is free software; Standard perl licence.
43
44 Mock-Quick is distributed in the hope that it will be useful, but
45 WITHOUT ANY WARRANTY; without even the implied warranty of
46 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license
47 for more details.
48
49
50
51perl v5.28.0 2018-07-14 Mock::Quick::Object(3)