line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::EasyMock::Class; |
2
|
1
|
|
|
1
|
|
1926
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Test::EasyMock::Class - support class method mocking. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Test::EasyMock qw(:all); |
12
|
|
|
|
|
|
|
use Test::EasyMock::Class qw(create_class_mock); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $mock = create_class_mock('Foo::Bar'); |
15
|
|
|
|
|
|
|
expect($mock->foo(1))->and_scalar_return('a'); |
16
|
|
|
|
|
|
|
replay($mock); |
17
|
|
|
|
|
|
|
Foo::Bar->foo(1); # return 'a' |
18
|
|
|
|
|
|
|
Foo::Bar->foo(2); # Unexpected method call.(A test is failed) |
19
|
|
|
|
|
|
|
verify($mock); # verify all expectations is invoked. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
1
|
|
|
1
|
|
4
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
23
|
1
|
|
|
1
|
|
727
|
use Test::EasyMock::MockControl::Class; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
114
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
26
|
|
|
|
|
|
|
create_class_mock |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT_OK]); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 FUNCTIONS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 create_class_mock($class) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Creates a mock object for class. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
sub create_class_mock { |
38
|
1
|
|
|
1
|
1
|
1087
|
my $control = Test::EasyMock::MockControl::Class->create_control(@_); |
39
|
1
|
|
|
|
|
8
|
return $control->create_mock; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |