| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=pod |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::Mockify - minimal mocking framework for perl |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Test::Mockify; |
|
10
|
|
|
|
|
|
|
use Test::Mockify::Verify qw ( WasCalled ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# build a new mocked object |
|
13
|
|
|
|
|
|
|
my $MockObjectBuilder = Test::Mockify->new('SampleLogger', []); |
|
14
|
|
|
|
|
|
|
my $returnValue = undef; |
|
15
|
|
|
|
|
|
|
my $expectedParameterTypes = ['string']; |
|
16
|
|
|
|
|
|
|
$MockObjectBuilder->mock('log', $returnValue, $expectedParameterTypes); |
|
17
|
|
|
|
|
|
|
my $MockedLogger = $MockLoggerBuilder->getMockObject(); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# inject mocked object into the code you want to test |
|
20
|
|
|
|
|
|
|
my $App = SampleApp->new('logger'=> $MockedLogger); |
|
21
|
|
|
|
|
|
|
$App->do_something(); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# verify that the mock object was called |
|
24
|
|
|
|
|
|
|
ok(WasCalled($MockedLogger, 'log'), 'log was called'); |
|
25
|
|
|
|
|
|
|
done_testing(); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Use L<Test::Mockify> to create and configure mock objects. Use L<Test::Mockify::Verify> to |
|
30
|
|
|
|
|
|
|
verify the interactions with your mocks. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package Test::Mockify; |
|
37
|
2
|
|
|
2
|
|
16717
|
use Test::Mockify::Tools qw ( Error ExistsMethod IsValid LoadPackage Isa ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
114
|
|
|
38
|
2
|
|
|
2
|
|
659
|
use Test::Mockify::TypeTests qw ( IsInteger IsFloat IsString IsArrayReference IsHashReference IsObjectReference ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
122
|
|
|
39
|
2
|
|
|
2
|
|
643
|
use Test::Mockify::MethodCallCounter; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
43
|
|
|
40
|
2
|
|
|
2
|
|
782
|
use Test::MockObject::Extends; |
|
|
2
|
|
|
|
|
10363
|
|
|
|
2
|
|
|
|
|
6
|
|
|
41
|
2
|
|
|
2
|
|
46
|
use Data::Dumper; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
98
|
|
|
42
|
2
|
|
|
2
|
|
11
|
use Scalar::Util qw( blessed ); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
78
|
|
|
43
|
2
|
|
|
2
|
|
845
|
use Data::Compare; |
|
|
2
|
|
|
|
|
15149
|
|
|
|
2
|
|
|
|
|
10
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
2
|
|
5813
|
use experimental 'switch'; |
|
|
2
|
|
|
|
|
4778
|
|
|
|
2
|
|
|
|
|
8
|
|
|
46
|
2
|
|
|
2
|
|
210
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
4431
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our $VERSION = '0.9'; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 new |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $MockObjectBuilder = Test::Mockify->new('Module::To::Mock', ['Constructor Parameters']); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 Options |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The C<new> method creates a new mock object builder. Use C<getMockObject> to obtain the final |
|
60
|
|
|
|
|
|
|
mock object. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
|
63
|
|
|
|
|
|
|
sub new { |
|
64
|
45
|
|
|
45
|
1
|
2153
|
my $class = shift; |
|
65
|
45
|
|
|
|
|
52
|
my ( $FakeModulePath, $aFakeParams ) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
45
|
|
|
|
|
61
|
my $self = bless {}, $class; |
|
68
|
|
|
|
|
|
|
|
|
69
|
45
|
|
|
|
|
97
|
LoadPackage( $FakeModulePath ); |
|
70
|
45
|
|
|
|
|
41
|
my $FakeClass = $FakeModulePath->new( @{$aFakeParams} ); |
|
|
45
|
|
|
|
|
125
|
|
|
71
|
45
|
|
|
|
|
302
|
$self->{'__MockedModulePath'} = $FakeModulePath; |
|
72
|
45
|
|
|
|
|
121
|
$self->{'__MockedModule'} = Test::MockObject::Extends->new( $FakeClass ); |
|
73
|
45
|
|
|
|
|
3073
|
$self->_initMockedModule(); |
|
74
|
|
|
|
|
|
|
|
|
75
|
45
|
|
|
|
|
74
|
return $self; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _initMockedModule { |
|
79
|
45
|
|
|
45
|
|
43
|
my $self = shift; |
|
80
|
|
|
|
|
|
|
|
|
81
|
45
|
|
|
|
|
91
|
$self->{'__MockedModule'}->{'__MethodCallCounter'} = Test::Mockify::MethodCallCounter->new(); |
|
82
|
45
|
|
|
|
|
56
|
$self->{'__MockedModule'}->{'__isMockified'} = 1; |
|
83
|
45
|
|
|
|
|
63
|
$self->_addGetParameterFromMockifyCall(); |
|
84
|
|
|
|
|
|
|
|
|
85
|
45
|
|
|
|
|
33
|
return; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 getMockObject |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Provides the actual mock object, which you can use in the test. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $aParameterList = ['SomeValueForConstructor']; |
|
96
|
|
|
|
|
|
|
my $MockObjectBuilder = Test::Mockify->new( 'My::Module', $aParameterList ); |
|
97
|
|
|
|
|
|
|
my $MyModuleObject = $MockObjectBuilder->getMockObject(); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
sub getMockObject { |
|
101
|
43
|
|
|
43
|
1
|
104
|
my $self = shift; |
|
102
|
43
|
|
|
|
|
65
|
return $self->{'__MockedModule'}; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 mock |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is a short cut for *addMock*, *addMockWithReturnValue* and *addMockWithReturnValueAndParameterCheck*. *mock* detects the required method with given parameters. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
| Parameter in *mock* | actually used method | |
|
113
|
|
|
|
|
|
|
| ------------- | ------------- | |
|
114
|
|
|
|
|
|
|
| mock('MethodName', sub{}) | *addMock* | |
|
115
|
|
|
|
|
|
|
| mock('MethodName', 'someValue') | *addMockWithReturnValue* | |
|
116
|
|
|
|
|
|
|
| mock('MethodName', 'someValue', ['string',{'string' => 'abcd'}]) | *addMockWithReturnValueAndParameterCheck* | |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
sub mock { |
|
120
|
3
|
|
|
3
|
1
|
18
|
my $self = shift; |
|
121
|
3
|
|
|
|
|
4
|
my @Parameters = @_; |
|
122
|
3
|
|
|
|
|
3
|
my $ParameterAmount = scalar @Parameters; |
|
123
|
3
|
100
|
|
|
|
8
|
if($ParameterAmount == 2){ |
|
124
|
2
|
|
|
|
|
3
|
my ( $MethodName, $ReturnValueOrFunctionPointer ) = @Parameters; |
|
125
|
2
|
100
|
|
|
|
5
|
if( ref($ReturnValueOrFunctionPointer) eq 'CODE' ){ |
|
126
|
1
|
|
|
|
|
2
|
$self->addMock($MethodName, $ReturnValueOrFunctionPointer); |
|
127
|
|
|
|
|
|
|
}else{ |
|
128
|
1
|
|
|
|
|
3
|
$self->addMockWithReturnValue($MethodName, $ReturnValueOrFunctionPointer); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
3
|
100
|
|
|
|
8
|
if($ParameterAmount == 3){ |
|
132
|
1
|
|
|
|
|
1
|
my ( $MethodName, $ReturnValue, $aParameterTypes ) = @_; |
|
133
|
1
|
|
|
|
|
3
|
$self->addMockWithReturnValueAndParameterCheck($MethodName, $ReturnValue, $aParameterTypes); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
3
|
|
|
|
|
4
|
return; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=pod |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 addMethodSpy |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
With this method it is possible to observe a method. That means, you keep the original functionality, but you can get meta data from the mockify- framework. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$MockObjectBuilder->addMethodSpy('myMethodName'); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
sub addMethodSpy { |
|
148
|
2
|
|
|
2
|
1
|
8
|
my $self = shift; |
|
149
|
2
|
|
|
|
|
3
|
my ( $MethodName ) = @_; |
|
150
|
|
|
|
|
|
|
|
|
151
|
2
|
|
|
|
|
2
|
my $PointerOriginalMethod = \&{$self->{'__MockedModulePath'}.'::'.$MethodName}; |
|
|
2
|
|
|
|
|
6
|
|
|
152
|
|
|
|
|
|
|
$self->addMock( $MethodName, sub { |
|
153
|
2
|
|
|
2
|
|
5
|
$PointerOriginalMethod->( @_ ); |
|
154
|
2
|
|
|
|
|
7
|
} ); |
|
155
|
|
|
|
|
|
|
|
|
156
|
2
|
|
|
|
|
2
|
return; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=pod |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 addMethodSpyWithParameterCheck |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
With this method it is possible to observe a method and check the parameters. That means, you keep the original functionality, but you can get meta data from the mockify- framework and use the parameter check, like *addMockWithReturnValueAndParameterCheck*. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $aParameterTypes = ['string',{'string' => 'abcd'}]; |
|
166
|
|
|
|
|
|
|
$MockObjectBuilder->addMethodSpyWithParameterCheck('myMethodName', $aParameterTypes); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head3 Options |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Pure types |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
['string', 'int', 'hashref', 'float', 'arrayref', 'object', 'undef', 'any'] |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
or types with expected values |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
[{'string'=>'abcdef'}, {'int' => 123}, {'float' => 1.23}, {'hashref' => {'key'=>'value'}}, {'arrayref'=>['one', 'two']}, {'object'=> 'PAth::to:Obejct}] |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
If you use *any*, you have to verify this value explicitly in the test, see **GetParametersFromMockifyCall** in L<Test::Mockify::Verify>. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
|
181
|
|
|
|
|
|
|
sub addMethodSpyWithParameterCheck { |
|
182
|
2
|
|
|
2
|
1
|
11
|
my $self = shift; |
|
183
|
2
|
|
|
|
|
3
|
my ( $MethodName, $aParameterTypes ) = @_; |
|
184
|
|
|
|
|
|
|
|
|
185
|
2
|
|
|
|
|
4
|
$self->_checkParameterTypesForMethod( $MethodName , $aParameterTypes ); |
|
186
|
2
|
|
|
|
|
2
|
my $PointerOriginalMethod = \&{$self->{'__MockedModulePath'}.'::'.$MethodName}; |
|
|
2
|
|
|
|
|
6
|
|
|
187
|
|
|
|
|
|
|
$self->addMock( $MethodName, sub { |
|
188
|
2
|
|
|
2
|
|
3
|
my $MockedSelf = shift; |
|
189
|
2
|
|
|
|
|
3
|
my @MockedParameters = @_; |
|
190
|
2
|
|
|
|
|
4
|
$self->_storeParameters( $MethodName, $MockedSelf, \@MockedParameters ); |
|
191
|
2
|
|
|
|
|
4
|
$self->_testParameterTypes( $MethodName , $aParameterTypes, \@MockedParameters ); |
|
192
|
1
|
|
|
|
|
2
|
$self->_testParameterAmount( $MethodName , $aParameterTypes, \@MockedParameters ); |
|
193
|
1
|
|
|
|
|
3
|
$PointerOriginalMethod->($MockedSelf, @MockedParameters); |
|
194
|
2
|
|
|
|
|
8
|
} ); |
|
195
|
2
|
|
|
|
|
3
|
return; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=pod |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 addMock |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This is the simplest case. It works like the mock-method from Test::MockObject. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Only handover the **name** and a **method pointer**. Mockify will automatically check if the method exists in the original object. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$MockObjectBuilder->addMock('myMethodName', sub { |
|
207
|
|
|
|
|
|
|
# Your implementation |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
); |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
|
212
|
|
|
|
|
|
|
sub addMock { |
|
213
|
41
|
|
|
41
|
1
|
71
|
my $self = shift; |
|
214
|
41
|
|
|
|
|
40
|
my ( $MethodName, $rSub ) = @_; |
|
215
|
|
|
|
|
|
|
|
|
216
|
41
|
|
|
|
|
85
|
ExistsMethod( $self->{'__MockedModulePath'}, $MethodName ); |
|
217
|
40
|
|
|
|
|
157
|
$self->{'__MockedModule'}->{'__MethodCallCounter'}->addMethod( $MethodName ); |
|
218
|
|
|
|
|
|
|
$self->{'__MockedModule'}->mock( $MethodName, sub { |
|
219
|
46
|
|
|
46
|
|
2788
|
$self->{'__MockedModule'}->{'__MethodCallCounter'}->increment( $MethodName ); |
|
220
|
46
|
|
|
|
|
65
|
return $rSub->( @_ ); |
|
221
|
40
|
|
|
|
|
168
|
} ); |
|
222
|
|
|
|
|
|
|
|
|
223
|
40
|
|
|
|
|
719
|
return; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=pod |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 addMockWithReturnValue |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Does the same as C<addMock>, but here you can handover a **value** which will be returned if you call the mocked method. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
$MockObjectBuilder->addMockWithReturnValue('myMethodName','the return value'); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |
|
235
|
|
|
|
|
|
|
sub addMockWithReturnValue { |
|
236
|
5
|
|
|
5
|
1
|
53
|
my $self = shift; |
|
237
|
5
|
|
|
|
|
6
|
my ( $MethodName, $ReturnValue ) = @_; |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
$self->addMock($MethodName, sub { |
|
240
|
4
|
|
|
4
|
|
5
|
my $MockedSelf = shift; |
|
241
|
4
|
|
|
|
|
4
|
my $ParameterListSize = scalar @_; |
|
242
|
|
|
|
|
|
|
|
|
243
|
4
|
100
|
|
|
|
7
|
if ( $ParameterListSize > 0 ){ |
|
244
|
1
|
|
|
|
|
7
|
Error('UnexpectedParameter',{ |
|
245
|
|
|
|
|
|
|
'Method' => "$self->{'__MockedModulePath'}->$MethodName", |
|
246
|
|
|
|
|
|
|
'ParameterList' => "(@_)", |
|
247
|
|
|
|
|
|
|
'AmountOfUnexpectedParameters' => $ParameterListSize, |
|
248
|
|
|
|
|
|
|
} ); |
|
249
|
|
|
|
|
|
|
} |
|
250
|
|
|
|
|
|
|
|
|
251
|
3
|
|
|
|
|
11
|
return $ReturnValue; |
|
252
|
5
|
|
|
|
|
20
|
} ); |
|
253
|
|
|
|
|
|
|
|
|
254
|
4
|
|
|
|
|
6
|
return; |
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=pod |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head2 addMockWithReturnValueAndParameterCheck |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This method is an extension of *addMockWithReturnValue*. Here you can also check the parameters which will be passed. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
You can check if they have a specific **data type** or even check if they have a given **value**. |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
In the following example two strings will be expected, and the second one has to have the value "abcd". |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my $aParameterTypes = ['string',{'string' => 'abcd'}]; |
|
268
|
|
|
|
|
|
|
$MockObjectBuilder->addMockWithReturnValueAndParameterCheck('myMethodName','the return value',$aParameterTypes); |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head3 Options |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Pure types |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
['string', 'int', 'float', 'hashref', 'arrayref', 'object', 'undef', 'any'] |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
or types with expected values |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
[{'string'=>'abcdef'}, {'int' => 123}, {'float' => 1.23}, {'hashref' => {'key'=>'value'}}, {'arrayref'=>['one', 'two']}, {'object'=> 'PAth::to:Obejct}] |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
If you use **any**, you have to verify this value explicitly in the test, see +*GetParametersFromMockifyCall** in L<Test::Mockify::Verify>. |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
|
283
|
|
|
|
|
|
|
sub addMockWithReturnValueAndParameterCheck { |
|
284
|
26
|
|
|
26
|
1
|
158
|
my $self = shift; |
|
285
|
26
|
|
|
|
|
35
|
my ( $MethodName, $ReturnValue, $aParameterTypes ) = @_; |
|
286
|
|
|
|
|
|
|
|
|
287
|
26
|
100
|
|
|
|
51
|
if ( not IsArrayReference( $aParameterTypes ) ){ |
|
288
|
|
|
|
|
|
|
Error( 'ParameterTypesNotProvided', { |
|
289
|
1
|
|
|
|
|
7
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
290
|
|
|
|
|
|
|
'ParameterList' => $aParameterTypes, |
|
291
|
|
|
|
|
|
|
} ); |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
$self->addMock( |
|
295
|
|
|
|
|
|
|
$MethodName, |
|
296
|
|
|
|
|
|
|
sub{ |
|
297
|
31
|
|
|
31
|
|
28
|
my $MockedSelf = shift; |
|
298
|
31
|
|
|
|
|
60
|
my @MockedParameters = @_; |
|
299
|
|
|
|
|
|
|
|
|
300
|
31
|
|
|
|
|
49
|
$self->_storeParameters( $MethodName, $MockedSelf, \@MockedParameters ); |
|
301
|
31
|
|
|
|
|
49
|
$self->_testParameterAmount( $MethodName , $aParameterTypes, \@MockedParameters ); |
|
302
|
30
|
|
|
|
|
51
|
$self->_testParameterTypes( $MethodName , $aParameterTypes, \@MockedParameters ); |
|
303
|
|
|
|
|
|
|
|
|
304
|
16
|
|
|
|
|
62
|
return $ReturnValue; |
|
305
|
|
|
|
|
|
|
} |
|
306
|
25
|
|
|
|
|
111
|
); |
|
307
|
|
|
|
|
|
|
|
|
308
|
25
|
|
|
|
|
37
|
return; |
|
309
|
|
|
|
|
|
|
} |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub _storeParameters { |
|
312
|
33
|
|
|
33
|
|
30
|
my $self = shift; |
|
313
|
|
|
|
|
|
|
|
|
314
|
33
|
|
|
|
|
30
|
my ( $MethodName, $MockedSelf, $aMockedParameters ) = @_; |
|
315
|
33
|
|
|
|
|
25
|
push( @{$MockedSelf->{$MethodName.'_MockifyParams'}}, $aMockedParameters ); |
|
|
33
|
|
|
|
|
102
|
|
|
316
|
|
|
|
|
|
|
|
|
317
|
33
|
|
|
|
|
41
|
return; |
|
318
|
|
|
|
|
|
|
} |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
sub _testParameterTypes { |
|
321
|
32
|
|
|
32
|
|
29
|
my $self = shift; |
|
322
|
32
|
|
|
|
|
24
|
my ( $MethodName, $aExpectedParameterTypes, $aActualInputParameters ) = @_; |
|
323
|
|
|
|
|
|
|
|
|
324
|
32
|
|
|
|
|
27
|
my @TestParameters = @{$aExpectedParameterTypes}; |
|
|
32
|
|
|
|
|
38
|
|
|
325
|
32
|
|
|
|
|
27
|
my @MockedParameters = @{$aActualInputParameters}; |
|
|
32
|
|
|
|
|
31
|
|
|
326
|
32
|
|
|
|
|
25
|
my $MockedParametersSize = scalar @MockedParameters; |
|
327
|
32
|
|
|
|
|
61
|
for ( my $i = 0; $i < $MockedParametersSize; $i++ ) { |
|
328
|
49
|
|
|
|
|
111
|
my $TypeTestResult = $self->_testParameterType("Parameter[$i]", $MockedParameters[$i], $TestParameters[$i], $MethodName ); |
|
329
|
35
|
100
|
|
|
|
87
|
if ( ! $TypeTestResult ){ |
|
330
|
|
|
|
|
|
|
Error( 'UnknownParametertype', { |
|
331
|
1
|
|
|
|
|
7
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
332
|
|
|
|
|
|
|
'UnknownParameterType' => $self->_getParameterType( $TestParameters[$i] ), |
|
333
|
|
|
|
|
|
|
'ParameterNumber'=> $i, |
|
334
|
|
|
|
|
|
|
} ); |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
} |
|
337
|
|
|
|
|
|
|
|
|
338
|
17
|
|
|
|
|
23
|
return; |
|
339
|
|
|
|
|
|
|
} |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
sub _testParameterType { |
|
342
|
49
|
|
|
49
|
|
34
|
my $self = shift; |
|
343
|
49
|
|
|
|
|
49
|
my ( $ParameterName, $Value, $TestParameter, $MethodName ) = @_; |
|
344
|
|
|
|
|
|
|
|
|
345
|
49
|
|
|
|
|
53
|
my $TestParameterType = $self->_getParameterType( $TestParameter ); |
|
346
|
49
|
|
|
|
|
67
|
foreach ( $TestParameterType ) { |
|
347
|
49
|
|
|
|
|
73
|
when( 'string' ) { |
|
348
|
15
|
|
|
|
|
24
|
$self->_testExpectedString( $ParameterName,$Value, $TestParameter ,$MethodName ); |
|
349
|
|
|
|
|
|
|
} |
|
350
|
34
|
|
|
|
|
30
|
when( 'int' ) { |
|
351
|
5
|
|
|
|
|
10
|
$self->_testExpectedInt( $ParameterName,$Value, $TestParameter, $MethodName ); |
|
352
|
|
|
|
|
|
|
} |
|
353
|
29
|
|
|
|
|
21
|
when( 'float' ) { |
|
354
|
3
|
|
|
|
|
6
|
$self->_testExpectedFloat( $ParameterName,$Value, $TestParameter, $MethodName ); |
|
355
|
|
|
|
|
|
|
} |
|
356
|
26
|
|
|
|
|
19
|
when( 'hashref' ) { |
|
357
|
6
|
|
|
|
|
13
|
$self->_testExpectedHashRef( $ParameterName,$Value, $TestParameter, $MethodName ); |
|
358
|
|
|
|
|
|
|
} |
|
359
|
20
|
|
|
|
|
18
|
when( 'arrayref' ) { |
|
360
|
5
|
|
|
|
|
11
|
$self->_testExpectedArrayRef( $ParameterName,$Value, $TestParameter, $MethodName ); |
|
361
|
|
|
|
|
|
|
} |
|
362
|
15
|
|
|
|
|
12
|
when( 'object' ) { |
|
363
|
8
|
|
|
|
|
12
|
$self->_testExpectedObject( $ParameterName,$Value, $TestParameter,$MethodName ); |
|
364
|
|
|
|
|
|
|
} |
|
365
|
7
|
|
|
|
|
4
|
when( 'undef' ) { |
|
366
|
6
|
|
|
|
|
11
|
$self->_testUndefind( $ParameterName,$Value,$MethodName ); |
|
367
|
|
|
|
|
|
|
} |
|
368
|
1
|
|
|
|
|
3
|
when( 'any' ) { |
|
369
|
0
|
|
|
|
|
0
|
return 1; |
|
370
|
|
|
|
|
|
|
} |
|
371
|
1
|
|
|
|
|
2
|
default { |
|
372
|
1
|
|
|
|
|
3
|
return 0; |
|
373
|
|
|
|
|
|
|
} |
|
374
|
|
|
|
|
|
|
} |
|
375
|
|
|
|
|
|
|
|
|
376
|
34
|
|
|
|
|
38
|
return 1; |
|
377
|
|
|
|
|
|
|
} |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub _addGetParameterFromMockifyCall { |
|
380
|
45
|
|
|
45
|
|
36
|
my $self = shift; |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
$self->{'__MockedModule'}->mock('__getParametersFromMockifyCall', |
|
383
|
|
|
|
|
|
|
sub{ |
|
384
|
10
|
|
|
10
|
|
421
|
my $MockedSelf = shift; |
|
385
|
10
|
|
|
|
|
11
|
my ( $MethodName, $Position ) = @_; |
|
386
|
|
|
|
|
|
|
|
|
387
|
10
|
|
|
|
|
23
|
my $aParametersFromAllCalls = $MockedSelf->{$MethodName.'_MockifyParams'}; |
|
388
|
10
|
100
|
|
|
|
48
|
if( ref $aParametersFromAllCalls ne 'ARRAY' ){ |
|
389
|
1
|
|
|
|
|
3
|
Error( "$MethodName was not called" ); |
|
390
|
|
|
|
|
|
|
} |
|
391
|
9
|
100
|
|
|
|
9
|
if( scalar @{$aParametersFromAllCalls} < $Position ) { |
|
|
9
|
|
|
|
|
26
|
|
|
392
|
1
|
|
|
|
|
10
|
Error( "$MethodName was not called ".( $Position+1 ).' times',{ |
|
393
|
|
|
|
|
|
|
'Method' => "$MethodName", |
|
394
|
|
|
|
|
|
|
'Postion' => $Position, |
|
395
|
|
|
|
|
|
|
} ); |
|
396
|
|
|
|
|
|
|
} |
|
397
|
|
|
|
|
|
|
else { |
|
398
|
8
|
|
|
|
|
15
|
my $ParameterFromMockifyCall = $MockedSelf->{$MethodName.'_MockifyParams'}[$Position]; |
|
399
|
8
|
|
|
|
|
30
|
return $ParameterFromMockifyCall; |
|
400
|
|
|
|
|
|
|
} |
|
401
|
0
|
|
|
|
|
0
|
return; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
45
|
|
|
|
|
232
|
); |
|
404
|
|
|
|
|
|
|
|
|
405
|
45
|
|
|
|
|
968
|
return; |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
sub _getParameterType { |
|
409
|
50
|
|
|
50
|
|
38
|
my $self = shift; |
|
410
|
50
|
|
|
|
|
40
|
my ( $TestParameter ) = @_; |
|
411
|
|
|
|
|
|
|
|
|
412
|
50
|
|
|
|
|
45
|
my $TestParameterType = undef; |
|
413
|
50
|
100
|
|
|
|
79
|
if( IsHashReference( $TestParameter ) ){ |
|
414
|
20
|
|
|
|
|
14
|
my @Keys = keys %{$TestParameter}; |
|
|
20
|
|
|
|
|
57
|
|
|
415
|
20
|
|
|
|
|
25
|
$TestParameterType = $Keys[0]; |
|
416
|
|
|
|
|
|
|
} else { |
|
417
|
30
|
|
|
|
|
27
|
$TestParameterType = $TestParameter; |
|
418
|
|
|
|
|
|
|
} |
|
419
|
|
|
|
|
|
|
|
|
420
|
50
|
|
|
|
|
58
|
return $TestParameterType; |
|
421
|
|
|
|
|
|
|
} |
|
422
|
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
sub _testParameterAmount { |
|
424
|
32
|
|
|
32
|
|
24
|
my $self = shift; |
|
425
|
32
|
|
|
|
|
26
|
my ( $MethodName , $aExpectedParameterTypes, $aActualInputParameters ) = @_; |
|
426
|
|
|
|
|
|
|
|
|
427
|
32
|
|
|
|
|
29
|
my $AmountExpectedParameterTypes = scalar @{$aExpectedParameterTypes}; |
|
|
32
|
|
|
|
|
33
|
|
|
428
|
32
|
|
|
|
|
23
|
my $AmountActualInputParameters = scalar @{$aActualInputParameters}; |
|
|
32
|
|
|
|
|
23
|
|
|
429
|
32
|
100
|
|
|
|
53
|
if( $AmountActualInputParameters != $AmountExpectedParameterTypes ){ |
|
430
|
|
|
|
|
|
|
Error( 'WrongAmountOfParameters', { |
|
431
|
1
|
|
|
|
|
5
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
432
|
|
|
|
|
|
|
'ExpectedAmount' => $AmountExpectedParameterTypes, |
|
433
|
|
|
|
|
|
|
'ActualAmount' => $AmountActualInputParameters, |
|
434
|
|
|
|
|
|
|
} ); |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
|
|
437
|
31
|
|
|
|
|
26
|
return; |
|
438
|
|
|
|
|
|
|
} |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
sub _testExpectedString { |
|
441
|
15
|
|
|
15
|
|
10
|
my $self = shift; |
|
442
|
15
|
|
|
|
|
17
|
my ( $Name, $Value, $TestParameterType, $MethodName ) = @_; |
|
443
|
|
|
|
|
|
|
|
|
444
|
15
|
100
|
|
|
|
26
|
if ( not IsString( $Value ) ) { |
|
445
|
|
|
|
|
|
|
Error( "$Name is not a String", { |
|
446
|
1
|
|
|
|
|
7
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
447
|
|
|
|
|
|
|
'Value' => $Value |
|
448
|
|
|
|
|
|
|
}); |
|
449
|
|
|
|
|
|
|
} |
|
450
|
14
|
100
|
|
|
|
23
|
if( IsHashReference( $TestParameterType ) ){ |
|
451
|
6
|
|
|
|
|
3
|
my @Values = values %{$TestParameterType}; |
|
|
6
|
|
|
|
|
13
|
|
|
452
|
6
|
|
|
|
|
7
|
my $ExpectedValue = $Values[0]; |
|
453
|
6
|
100
|
|
|
|
14
|
if( $Value ne $ExpectedValue ){ |
|
454
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
455
|
1
|
|
|
|
|
12
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
456
|
|
|
|
|
|
|
'ActualValue' => $Value, |
|
457
|
|
|
|
|
|
|
'ExpectedValue' => $ExpectedValue, |
|
458
|
|
|
|
|
|
|
}); |
|
459
|
|
|
|
|
|
|
} |
|
460
|
|
|
|
|
|
|
} |
|
461
|
|
|
|
|
|
|
|
|
462
|
13
|
|
|
|
|
25
|
return; |
|
463
|
|
|
|
|
|
|
} |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
sub _testExpectedInt { |
|
466
|
5
|
|
|
5
|
|
7
|
my $self = shift; |
|
467
|
5
|
|
|
|
|
9
|
my ( $Name, $Value, $hTestParameterType, $MethodName ) = @_; |
|
468
|
|
|
|
|
|
|
|
|
469
|
5
|
100
|
|
|
|
11
|
if ( not IsInteger( $Value ) ) { |
|
470
|
|
|
|
|
|
|
Error( "$Name is not an Integer", { |
|
471
|
1
|
|
|
|
|
18
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
472
|
|
|
|
|
|
|
'Value' => $Value |
|
473
|
|
|
|
|
|
|
}); |
|
474
|
|
|
|
|
|
|
} |
|
475
|
4
|
100
|
|
|
|
9
|
if( IsHashReference( $hTestParameterType ) ){ |
|
476
|
2
|
|
|
|
|
3
|
my @Values = values %{$hTestParameterType}; |
|
|
2
|
|
|
|
|
6
|
|
|
477
|
2
|
|
|
|
|
3
|
my $ExpectedValue = $Values[0]; |
|
478
|
2
|
100
|
|
|
|
7
|
if( $Value != $ExpectedValue ){ |
|
479
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
480
|
1
|
|
|
|
|
12
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
481
|
|
|
|
|
|
|
'ActualValue' => $Value, |
|
482
|
|
|
|
|
|
|
'ExpectedValue' => $ExpectedValue, |
|
483
|
|
|
|
|
|
|
}); |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
|
|
487
|
3
|
|
|
|
|
8
|
return; |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
sub _testExpectedFloat { |
|
491
|
3
|
|
|
3
|
|
9
|
my $self = shift; |
|
492
|
3
|
|
|
|
|
12
|
my ( $Name, $Value, $hTestParameterType, $MethodName ) = @_; |
|
493
|
|
|
|
|
|
|
|
|
494
|
3
|
100
|
|
|
|
8
|
if ( not IsFloat( $Value ) ) { |
|
495
|
|
|
|
|
|
|
Error( "$Name is not an Float", { |
|
496
|
1
|
|
|
|
|
15
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
497
|
|
|
|
|
|
|
'Value' => $Value |
|
498
|
|
|
|
|
|
|
}); |
|
499
|
|
|
|
|
|
|
} |
|
500
|
2
|
50
|
|
|
|
6
|
if( IsHashReference( $hTestParameterType ) ){ |
|
501
|
2
|
|
|
|
|
2
|
my @Values = values %{$hTestParameterType}; |
|
|
2
|
|
|
|
|
6
|
|
|
502
|
2
|
|
|
|
|
2
|
my $ExpectedValue = $Values[0]; |
|
503
|
2
|
100
|
|
|
|
7
|
if( $Value != $ExpectedValue ){ |
|
504
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
505
|
1
|
|
|
|
|
9
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
506
|
|
|
|
|
|
|
'ActualValue' => $Value, |
|
507
|
|
|
|
|
|
|
'ExpectedValue' => $ExpectedValue, |
|
508
|
|
|
|
|
|
|
}); |
|
509
|
|
|
|
|
|
|
} |
|
510
|
|
|
|
|
|
|
} |
|
511
|
|
|
|
|
|
|
|
|
512
|
1
|
|
|
|
|
4
|
return; |
|
513
|
|
|
|
|
|
|
} |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
sub _testUndefind { |
|
516
|
6
|
|
|
6
|
|
4
|
my $self = shift; |
|
517
|
6
|
|
|
|
|
9
|
my ( $Name, $Value, $MethodName ) = @_; |
|
518
|
|
|
|
|
|
|
|
|
519
|
6
|
100
|
|
|
|
11
|
if ( IsValid( $Value ) ) { |
|
520
|
|
|
|
|
|
|
Error( "$Name is not undefined", { |
|
521
|
1
|
|
|
|
|
7
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
522
|
|
|
|
|
|
|
'Value' => $Value |
|
523
|
|
|
|
|
|
|
}); |
|
524
|
|
|
|
|
|
|
} |
|
525
|
|
|
|
|
|
|
|
|
526
|
5
|
|
|
|
|
8
|
return; |
|
527
|
|
|
|
|
|
|
} |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
sub _testExpectedHashRef { |
|
530
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
|
531
|
6
|
|
|
|
|
6
|
my ( $Name, $Value, $TestParameterType, $MethodName ) = @_; |
|
532
|
|
|
|
|
|
|
|
|
533
|
6
|
100
|
|
|
|
13
|
if ( not IsHashReference( $Value ) ) { |
|
534
|
|
|
|
|
|
|
Error( "$Name is not a HashRef", { |
|
535
|
2
|
|
|
|
|
14
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
536
|
|
|
|
|
|
|
'Value' => $Value |
|
537
|
|
|
|
|
|
|
}); |
|
538
|
|
|
|
|
|
|
} |
|
539
|
4
|
100
|
|
|
|
6
|
if( IsHashReference( $TestParameterType ) ){ |
|
540
|
2
|
|
|
|
|
2
|
my @Values = values %{$TestParameterType}; |
|
|
2
|
|
|
|
|
4
|
|
|
541
|
2
|
|
|
|
|
3
|
my $ExpectedValue = $Values[0]; |
|
542
|
2
|
|
|
|
|
9
|
my $Compare = Data::Compare->new(); |
|
543
|
2
|
100
|
|
|
|
21
|
if( not $Compare->Cmp($Value,$ExpectedValue) ){ |
|
544
|
1
|
|
|
|
|
44
|
my $DumpedValue = Dumper( $Value ); |
|
545
|
1
|
|
|
|
|
48
|
my $DumpedExpected = Dumper( $ExpectedValue ); |
|
546
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
547
|
1
|
|
|
|
|
37
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName(???)", |
|
548
|
|
|
|
|
|
|
'got value' => $DumpedValue, |
|
549
|
|
|
|
|
|
|
'expected value' => $DumpedExpected, |
|
550
|
|
|
|
|
|
|
} ); |
|
551
|
|
|
|
|
|
|
} |
|
552
|
|
|
|
|
|
|
} |
|
553
|
|
|
|
|
|
|
|
|
554
|
3
|
|
|
|
|
118
|
return; |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
sub _testExpectedArrayRef { |
|
558
|
5
|
|
|
5
|
|
5
|
my $self = shift; |
|
559
|
5
|
|
|
|
|
7
|
my ( $Name, $Value, $TestParameterType, $MethodName ) = @_; |
|
560
|
|
|
|
|
|
|
|
|
561
|
5
|
100
|
|
|
|
8
|
if ( not IsArrayReference( $Value ) ) { |
|
562
|
|
|
|
|
|
|
Error( "$Name is not an ArrayRef", { |
|
563
|
1
|
|
|
|
|
7
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
564
|
|
|
|
|
|
|
'Value' => $Value |
|
565
|
|
|
|
|
|
|
} ); |
|
566
|
|
|
|
|
|
|
} |
|
567
|
4
|
100
|
|
|
|
6
|
if( IsHashReference( $TestParameterType ) ){ |
|
568
|
2
|
|
|
|
|
2
|
my @Values = values %{$TestParameterType}; |
|
|
2
|
|
|
|
|
4
|
|
|
569
|
2
|
|
|
|
|
3
|
my $ExpectedValue = $Values[0]; |
|
570
|
2
|
|
|
|
|
8
|
my $Compare = Data::Compare->new(); |
|
571
|
2
|
100
|
|
|
|
15
|
if( not $Compare->Cmp($Value,$ExpectedValue) ){ |
|
572
|
1
|
|
|
|
|
34
|
my $DumpedValue = Dumper( $Value ); |
|
573
|
1
|
|
|
|
|
46
|
my $DumpedExpected = Dumper( $ExpectedValue ); |
|
574
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
575
|
1
|
|
|
|
|
37
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName(???)", |
|
576
|
|
|
|
|
|
|
'got value' => $DumpedValue, |
|
577
|
|
|
|
|
|
|
'expected value' => $DumpedExpected, |
|
578
|
|
|
|
|
|
|
} ); |
|
579
|
|
|
|
|
|
|
} |
|
580
|
|
|
|
|
|
|
} |
|
581
|
|
|
|
|
|
|
|
|
582
|
3
|
|
|
|
|
87
|
return; |
|
583
|
|
|
|
|
|
|
} |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub _testExpectedObject { |
|
586
|
8
|
|
|
8
|
|
8
|
my $self = shift; |
|
587
|
8
|
|
|
|
|
9
|
my ( $Name, $Value, $TestParameterType, $MethodName ) = @_; |
|
588
|
|
|
|
|
|
|
|
|
589
|
8
|
100
|
|
|
|
13
|
if ( not IsObjectReference($Value) ) { |
|
590
|
|
|
|
|
|
|
Error( "$Name is not a Object", { |
|
591
|
1
|
|
|
|
|
6
|
'Method' => $self->{'__MockedModulePath'}."->$MethodName", |
|
592
|
|
|
|
|
|
|
'Value' => $Value |
|
593
|
|
|
|
|
|
|
} ); |
|
594
|
|
|
|
|
|
|
} |
|
595
|
7
|
100
|
|
|
|
9
|
if( IsHashReference( $TestParameterType ) ){ |
|
596
|
5
|
|
|
|
|
6
|
my @Values = values %{$TestParameterType}; |
|
|
5
|
|
|
|
|
7
|
|
|
597
|
5
|
|
|
|
|
5
|
my $ExpectedValue = $Values[0]; |
|
598
|
5
|
100
|
|
|
|
10
|
if( not Isa( $Value, $ExpectedValue ) ){ |
|
599
|
|
|
|
|
|
|
Error( "$Name unexpected value", { |
|
600
|
1
|
|
|
|
|
8
|
'Method' => $self->{'__MockedModulePath'}."::MethodName", |
|
601
|
|
|
|
|
|
|
'ActualObjectType' => blessed($Value), |
|
602
|
|
|
|
|
|
|
'ExpectedObjectType' => $ExpectedValue, |
|
603
|
|
|
|
|
|
|
}); |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
} |
|
606
|
|
|
|
|
|
|
|
|
607
|
6
|
|
|
|
|
12
|
return; |
|
608
|
|
|
|
|
|
|
} |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
sub _checkParameterTypesForMethod { |
|
611
|
2
|
|
|
2
|
|
2
|
my $self = shift; |
|
612
|
2
|
|
|
|
|
2
|
my ( $MethodName, $aParameterTypes ) = @_; |
|
613
|
|
|
|
|
|
|
|
|
614
|
2
|
50
|
33
|
|
|
8
|
if ( not ( defined $aParameterTypes ) or not IsArrayReference( $aParameterTypes )){ |
|
615
|
|
|
|
|
|
|
Error( 'ParameterTypesNotProvided', { |
|
616
|
0
|
|
|
|
|
0
|
'Method' => $self->{'__MockedModulePath'}."::MethodName", |
|
617
|
|
|
|
|
|
|
} ); |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
|
|
620
|
2
|
|
|
|
|
3
|
return; |
|
621
|
|
|
|
|
|
|
} |
|
622
|
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
1; |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
__END__ |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
=head1 LICENSE |
|
628
|
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
Copyright (C) 2017 ePages GmbH |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
632
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=head1 AUTHOR |
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
Christian Breitkreutz E<lt>cbreitkreutz@epages.comE<gt> |
|
637
|
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=cut |
|
639
|
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
|