line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mocha::MethodStub; |
2
|
|
|
|
|
|
|
# ABSTRACT: Objects to represent stubbed methods with arguments and responses |
3
|
|
|
|
|
|
|
$Test::Mocha::MethodStub::VERSION = '0.67'; |
4
|
13
|
|
|
13
|
|
101
|
use parent 'Test::Mocha::Method'; |
|
13
|
|
|
|
|
192
|
|
|
13
|
|
|
|
|
96
|
|
5
|
13
|
|
|
13
|
|
917
|
use strict; |
|
13
|
|
|
|
|
46
|
|
|
13
|
|
|
|
|
285
|
|
6
|
13
|
|
|
13
|
|
66
|
use warnings; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
3259
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
# uncoverable pod |
10
|
91
|
|
|
91
|
0
|
579
|
my $class = shift; |
11
|
91
|
|
|
|
|
293
|
my $self = $class->SUPER::new(@_); |
12
|
|
|
|
|
|
|
|
13
|
91
|
|
50
|
|
|
694
|
$self->{responses} ||= []; # ArrayRef[ CodeRef ] |
14
|
|
|
|
|
|
|
|
15
|
91
|
|
|
|
|
347
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub __responses { |
19
|
155
|
|
|
155
|
|
275
|
my ($self) = @_; |
20
|
155
|
|
|
|
|
451
|
return $self->{responses}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub cast { |
24
|
|
|
|
|
|
|
# """Convert the type of the given object to this class""" |
25
|
|
|
|
|
|
|
# uncoverable pod |
26
|
60
|
|
|
60
|
0
|
150
|
my ( $class, $obj ) = @_; |
27
|
60
|
|
50
|
|
|
327
|
$obj->{responses} ||= []; |
28
|
60
|
|
|
|
|
139
|
return bless $obj, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub execute_next_response { |
32
|
|
|
|
|
|
|
# uncoverable pod |
33
|
95
|
|
|
95
|
0
|
241
|
my ( $self, @args ) = @_; |
34
|
95
|
|
|
|
|
222
|
my $responses = $self->__responses; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# return undef by default |
37
|
95
|
100
|
|
|
|
145
|
return if @{$responses} == 0; |
|
95
|
|
|
|
|
354
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# shift the next response off the front of the queue |
40
|
|
|
|
|
|
|
# ... except for the last one |
41
|
|
|
|
|
|
|
my $response = |
42
|
91
|
100
|
|
|
|
133
|
@{$responses} > 1 ? shift( @{$responses} ) : $responses->[0]; |
|
91
|
|
|
|
|
239
|
|
|
12
|
|
|
|
|
28
|
|
43
|
|
|
|
|
|
|
|
44
|
91
|
|
|
|
|
279
|
return $response->(@args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |