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.66'; |
4
|
13
|
|
|
13
|
|
107
|
use parent 'Test::Mocha::Method'; |
|
13
|
|
|
|
|
203
|
|
|
13
|
|
|
|
|
95
|
|
5
|
13
|
|
|
13
|
|
882
|
use strict; |
|
13
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
271
|
|
6
|
13
|
|
|
13
|
|
70
|
use warnings; |
|
13
|
|
|
|
|
39
|
|
|
13
|
|
|
|
|
3165
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
# uncoverable pod |
10
|
91
|
|
|
91
|
0
|
570
|
my $class = shift; |
11
|
91
|
|
|
|
|
294
|
my $self = $class->SUPER::new(@_); |
12
|
|
|
|
|
|
|
|
13
|
91
|
|
50
|
|
|
659
|
$self->{responses} ||= []; # ArrayRef[ CodeRef ] |
14
|
|
|
|
|
|
|
|
15
|
91
|
|
|
|
|
357
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub __responses { |
19
|
155
|
|
|
155
|
|
250
|
my ($self) = @_; |
20
|
155
|
|
|
|
|
437
|
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
|
118
|
my ( $class, $obj ) = @_; |
27
|
60
|
|
50
|
|
|
314
|
$obj->{responses} ||= []; |
28
|
60
|
|
|
|
|
130
|
return bless $obj, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub execute_next_response { |
32
|
|
|
|
|
|
|
# uncoverable pod |
33
|
95
|
|
|
95
|
0
|
230
|
my ( $self, @args ) = @_; |
34
|
95
|
|
|
|
|
207
|
my $responses = $self->__responses; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# return undef by default |
37
|
95
|
100
|
|
|
|
146
|
return if @{$responses} == 0; |
|
95
|
|
|
|
|
294
|
|
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
|
|
|
|
|
207
|
|
|
12
|
|
|
|
|
23
|
|
43
|
|
|
|
|
|
|
|
44
|
91
|
|
|
|
|
322
|
return $response->(@args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |