Skip to content

Commit 7c92739

Browse files
Fixed tests
1 parent 8425778 commit 7c92739

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/unit/Formatter/ClassFormatterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected function createReflectionClassMock(): MockObject
2020
'getShortName',
2121
'getName',
2222
'getDocComment',
23+
'getAttributes',
2324
'isInterface',
2425
'isTrait',
2526
'isAbstract',
@@ -46,6 +47,7 @@ public function testSimpleClass(): void
4647
$reflectionClass->method('getShortName')->willReturn('TestClass');
4748
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestClass');
4849
$reflectionClass->method('getDocComment')->willReturn(false);
50+
$reflectionClass->method('getAttributes')->willReturn([]);
4951
$reflectionClass->method('isInterface')->willReturn(false);
5052
$reflectionClass->method('isTrait')->willReturn(false);
5153
$reflectionClass->method('isAbstract')->willReturn(false);
@@ -77,6 +79,7 @@ public function testSimpleInterface(): void
7779
$reflectionClass->method('getShortName')->willReturn('TestInterface');
7880
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestInterface');
7981
$reflectionClass->method('getDocComment')->willReturn(false);
82+
$reflectionClass->method('getAttributes')->willReturn([]);
8083
$reflectionClass->method('isInterface')->willReturn(true);
8184
$reflectionClass->method('isTrait')->willReturn(false);
8285
$reflectionClass->method('isAbstract')->willReturn(false);
@@ -109,6 +112,7 @@ public function testSimpleTrait(): void
109112
$reflectionClass->method('getShortName')->willReturn('TestTrait');
110113
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestTrait');
111114
$reflectionClass->method('getDocComment')->willReturn(false);
115+
$reflectionClass->method('getAttributes')->willReturn([]);
112116
$reflectionClass->method('isInterface')->willReturn(false);
113117
$reflectionClass->method('isTrait')->willReturn(true);
114118
$reflectionClass->method('isAbstract')->willReturn(false);
@@ -141,6 +145,7 @@ public function testSimpleAbstract(): void
141145
$reflectionClass->method('getShortName')->willReturn('TestAbstract');
142146
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestAbstract');
143147
$reflectionClass->method('getDocComment')->willReturn(false);
148+
$reflectionClass->method('getAttributes')->willReturn([]);
144149
$reflectionClass->method('isInterface')->willReturn(false);
145150
$reflectionClass->method('isTrait')->willReturn(false);
146151
$reflectionClass->method('isAbstract')->willReturn(true);
@@ -173,6 +178,7 @@ public function testSimpleFinal(): void
173178
$reflectionClass->method('getShortName')->willReturn('TestFinal');
174179
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestFinal');
175180
$reflectionClass->method('getDocComment')->willReturn(false);
181+
$reflectionClass->method('getAttributes')->willReturn([]);
176182
$reflectionClass->method('isInterface')->willReturn(false);
177183
$reflectionClass->method('isTrait')->willReturn(false);
178184
$reflectionClass->method('isAbstract')->willReturn(false);
@@ -205,6 +211,7 @@ public function testComplexClass(): void
205211
$interfaceFromParent->method('getShortName')->willReturn('AnotherInterface');
206212
$interfaceFromParent->method('getName')->willReturn('vendor\library\TestStuff\AnotherInterface');
207213
$interfaceFromParent->method('getDocComment')->willReturn(false);
214+
$interfaceFromParent->method('getAttributes')->willReturn([]);
208215
$interfaceFromParent->method('isInterface')->willReturn(true);
209216
$interfaceFromParent->method('isTrait')->willReturn(false);
210217
$interfaceFromParent->method('isAbstract')->willReturn(false);
@@ -220,6 +227,7 @@ public function testComplexClass(): void
220227
$parent->method('getShortName')->willReturn('AnotherClass');
221228
$parent->method('getName')->willReturn('vendor\library\TestStuff\AnotherClass');
222229
$parent->method('getDocComment')->willReturn(false);
230+
$parent->method('getAttributes')->willReturn([]);
223231
$parent->method('isInterface')->willReturn(false);
224232
$parent->method('isTrait')->willReturn(false);
225233
$parent->method('isAbstract')->willReturn(false);
@@ -237,6 +245,7 @@ public function testComplexClass(): void
237245
$interfaceFromInterface->method('getShortName')->willReturn('SomeOtherInterface');
238246
$interfaceFromInterface->method('getName')->willReturn('vendor\library\TestStuff\SomeOtherInterface');
239247
$interfaceFromInterface->method('getDocComment')->willReturn(false);
248+
$interfaceFromInterface->method('getAttributes')->willReturn([]);
240249
$interfaceFromInterface->method('isInterface')->willReturn(true);
241250
$interfaceFromInterface->method('isTrait')->willReturn(false);
242251
$interfaceFromInterface->method('isAbstract')->willReturn(false);
@@ -252,6 +261,7 @@ public function testComplexClass(): void
252261
$interfaceA->method('getShortName')->willReturn('InterfaceA');
253262
$interfaceA->method('getName')->willReturn('vendor\library\TestStuff\InterfaceA');
254263
$interfaceA->method('getDocComment')->willReturn(false);
264+
$interfaceA->method('getAttributes')->willReturn([]);
255265
$interfaceA->method('isInterface')->willReturn(true);
256266
$interfaceA->method('isTrait')->willReturn(false);
257267
$interfaceA->method('isAbstract')->willReturn(false);
@@ -269,6 +279,7 @@ public function testComplexClass(): void
269279
$interfaceB->method('getShortName')->willReturn('InterfaceB');
270280
$interfaceB->method('getName')->willReturn('vendor\library\TestStuff\InterfaceB');
271281
$interfaceB->method('getDocComment')->willReturn(false);
282+
$interfaceB->method('getAttributes')->willReturn([]);
272283
$interfaceB->method('isInterface')->willReturn(true);
273284
$interfaceB->method('isTrait')->willReturn(false);
274285
$interfaceB->method('isAbstract')->willReturn(false);
@@ -294,6 +305,7 @@ public function testComplexClass(): void
294305
*/
295306
EOT
296307
);
308+
$reflectionClass->method('getAttributes')->willReturn([]);
297309
$reflectionClass->method('isInterface')->willReturn(false);
298310
$reflectionClass->method('isTrait')->willReturn(false);
299311
$reflectionClass->method('isAbstract')->willReturn(false);
@@ -340,6 +352,7 @@ public function testComplexInterface(): void
340352
$interfaceFromInterface->method('getShortName')->willReturn('SomeOtherInterface');
341353
$interfaceFromInterface->method('getName')->willReturn('vendor\library\TestStuff\SomeOtherInterface');
342354
$interfaceFromInterface->method('getDocComment')->willReturn(false);
355+
$interfaceFromInterface->method('getAttributes')->willReturn([]);
343356
$interfaceFromInterface->method('isInterface')->willReturn(true);
344357
$interfaceFromInterface->method('isTrait')->willReturn(false);
345358
$interfaceFromInterface->method('isAbstract')->willReturn(false);
@@ -355,6 +368,7 @@ public function testComplexInterface(): void
355368
$interfaceA->method('getShortName')->willReturn('InterfaceA');
356369
$interfaceA->method('getName')->willReturn('vendor\library\TestStuff\InterfaceA');
357370
$interfaceA->method('getDocComment')->willReturn(false);
371+
$interfaceA->method('getAttributes')->willReturn([]);
358372
$interfaceA->method('isInterface')->willReturn(true);
359373
$interfaceA->method('isTrait')->willReturn(false);
360374
$interfaceA->method('isAbstract')->willReturn(false);
@@ -372,6 +386,7 @@ public function testComplexInterface(): void
372386
$interfaceB->method('getShortName')->willReturn('InterfaceB');
373387
$interfaceB->method('getName')->willReturn('vendor\library\TestStuff\InterfaceB');
374388
$interfaceB->method('getDocComment')->willReturn(false);
389+
$interfaceB->method('getAttributes')->willReturn([]);
375390
$interfaceB->method('isInterface')->willReturn(true);
376391
$interfaceB->method('isTrait')->willReturn(false);
377392
$interfaceB->method('isAbstract')->willReturn(false);
@@ -397,6 +412,7 @@ public function testComplexInterface(): void
397412
*/
398413
EOT
399414
);
415+
$reflectionClass->method('getAttributes')->willReturn([]);
400416
$reflectionClass->method('isInterface')->willReturn(true);
401417
$reflectionClass->method('isTrait')->willReturn(false);
402418
$reflectionClass->method('isAbstract')->willReturn(false);

tests/unit/Formatter/MethodFormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ protected function createReflectionMethodMock(
9292
'hasReturnType',
9393
'getReturnType',
9494
'getDocComment',
95+
'getAttributes',
9596
'isAbstract',
9697
'isFinal',
9798
'isPublic',
@@ -134,6 +135,7 @@ protected function createReflectionMethodMock(
134135

135136
/** @noinspection ProperNullCoalescingOperatorUsageInspection */
136137
$result->method('getDocComment')->willReturn($doc ?? false);
138+
$result->method('getAttributes')->willReturn([]);
137139

138140
return $result;
139141
}

0 commit comments

Comments
 (0)