File tree Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 21
21
"ext-mbstring" : " *" ,
22
22
"behat/gherkin" : " ^4.6.2" ,
23
23
"codeception/lib-asserts" : " 2.0.*@dev" ,
24
- "codeception/stub" : " ^3.7 | ^4.0 " ,
24
+ "codeception/stub" : " ^4.1 " ,
25
25
"phpunit/phpunit" : " ^9.5" ,
26
26
"phpunit/php-code-coverage" : " ^9.2" ,
27
27
"phpunit/php-text-template" : " ^2.0" ,
Original file line number Diff line number Diff line change @@ -185,8 +185,24 @@ protected function getClassName(object $argument): string
185
185
{
186
186
if ($ argument instanceof Closure) {
187
187
return Closure::class;
188
- } elseif ($ argument instanceof MockObject && (property_exists ($ argument , '__mocked ' ) && $ argument ->__mocked !== null )) {
189
- return $ this ->formatClassName ($ argument ->__mocked );
188
+ } elseif ($ argument instanceof MockObject) {
189
+ $ parentClass = get_parent_class ($ argument );
190
+ $ reflection = new \ReflectionClass ($ argument );
191
+
192
+ if ($ parentClass !== false ) {
193
+ return $ this ->formatClassName ($ parentClass );
194
+ }
195
+
196
+ $ interfaces = $ reflection ->getInterfaceNames ();
197
+ foreach ($ interfaces as $ interface ) {
198
+ if (str_starts_with ($ interface , 'PHPUnit \\' )) {
199
+ continue ;
200
+ }
201
+ if (str_starts_with ($ interface , 'Codeception \\' )) {
202
+ continue ;
203
+ }
204
+ return $ this ->formatClassName ($ interface );
205
+ }
190
206
}
191
207
192
208
return $ this ->formatClassName ($ argument ::class);
Original file line number Diff line number Diff line change @@ -57,15 +57,11 @@ public function exceptionalMethod(): void
57
57
58
58
public function __get ($ name )
59
59
{
60
- //seeing as we're not implementing __set here, add check for __mocked
61
- $ return = null ;
62
- if ($ name === '__mocked ' ) {
63
- $ return = $ this ->__mocked ?? null ;
64
- } elseif ($ this ->__isset ($ name )) {
65
- $ return = $ this ->properties [$ name ];
60
+ if ($ this ->__isset ($ name )) {
61
+ return $ this ->properties [$ name ];
66
62
}
67
63
68
- return $ return ;
64
+ return null ;
69
65
}
70
66
71
67
public function __isset ($ name )
Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ public function testGetArguments()
43
43
44
44
$ mock = $ this ->createMock ($ this ::class);
45
45
$ step = $ this ->getStep (['' , [[$ mock , 'testGetArguments ' ]]]);
46
- $ className = $ mock ::class;
47
- $ this ->assertSame ('[" ' . $ className . '","testGetArguments"] ' , $ step ->getArgumentsAsString ());
46
+ $ this ->assertSame ('["StepTest","testGetArguments"] ' , $ step ->getArgumentsAsString ());
48
47
}
49
48
50
49
public function testGetHtml ()
You can’t perform that action at this time.
0 commit comments