Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianKresse committed Nov 21, 2024
1 parent 8425778 commit 7c92739
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/Formatter/ClassFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected function createReflectionClassMock(): MockObject
'getShortName',
'getName',
'getDocComment',
'getAttributes',
'isInterface',
'isTrait',
'isAbstract',
Expand All @@ -46,6 +47,7 @@ public function testSimpleClass(): void
$reflectionClass->method('getShortName')->willReturn('TestClass');
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestClass');
$reflectionClass->method('getDocComment')->willReturn(false);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(false);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down Expand Up @@ -77,6 +79,7 @@ public function testSimpleInterface(): void
$reflectionClass->method('getShortName')->willReturn('TestInterface');
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestInterface');
$reflectionClass->method('getDocComment')->willReturn(false);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(true);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down Expand Up @@ -109,6 +112,7 @@ public function testSimpleTrait(): void
$reflectionClass->method('getShortName')->willReturn('TestTrait');
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestTrait');
$reflectionClass->method('getDocComment')->willReturn(false);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(false);
$reflectionClass->method('isTrait')->willReturn(true);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down Expand Up @@ -141,6 +145,7 @@ public function testSimpleAbstract(): void
$reflectionClass->method('getShortName')->willReturn('TestAbstract');
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestAbstract');
$reflectionClass->method('getDocComment')->willReturn(false);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(false);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(true);
Expand Down Expand Up @@ -173,6 +178,7 @@ public function testSimpleFinal(): void
$reflectionClass->method('getShortName')->willReturn('TestFinal');
$reflectionClass->method('getName')->willReturn('vendor\library\TestStuff\TestFinal');
$reflectionClass->method('getDocComment')->willReturn(false);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(false);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down Expand Up @@ -205,6 +211,7 @@ public function testComplexClass(): void
$interfaceFromParent->method('getShortName')->willReturn('AnotherInterface');
$interfaceFromParent->method('getName')->willReturn('vendor\library\TestStuff\AnotherInterface');
$interfaceFromParent->method('getDocComment')->willReturn(false);
$interfaceFromParent->method('getAttributes')->willReturn([]);
$interfaceFromParent->method('isInterface')->willReturn(true);
$interfaceFromParent->method('isTrait')->willReturn(false);
$interfaceFromParent->method('isAbstract')->willReturn(false);
Expand All @@ -220,6 +227,7 @@ public function testComplexClass(): void
$parent->method('getShortName')->willReturn('AnotherClass');
$parent->method('getName')->willReturn('vendor\library\TestStuff\AnotherClass');
$parent->method('getDocComment')->willReturn(false);
$parent->method('getAttributes')->willReturn([]);
$parent->method('isInterface')->willReturn(false);
$parent->method('isTrait')->willReturn(false);
$parent->method('isAbstract')->willReturn(false);
Expand All @@ -237,6 +245,7 @@ public function testComplexClass(): void
$interfaceFromInterface->method('getShortName')->willReturn('SomeOtherInterface');
$interfaceFromInterface->method('getName')->willReturn('vendor\library\TestStuff\SomeOtherInterface');
$interfaceFromInterface->method('getDocComment')->willReturn(false);
$interfaceFromInterface->method('getAttributes')->willReturn([]);
$interfaceFromInterface->method('isInterface')->willReturn(true);
$interfaceFromInterface->method('isTrait')->willReturn(false);
$interfaceFromInterface->method('isAbstract')->willReturn(false);
Expand All @@ -252,6 +261,7 @@ public function testComplexClass(): void
$interfaceA->method('getShortName')->willReturn('InterfaceA');
$interfaceA->method('getName')->willReturn('vendor\library\TestStuff\InterfaceA');
$interfaceA->method('getDocComment')->willReturn(false);
$interfaceA->method('getAttributes')->willReturn([]);
$interfaceA->method('isInterface')->willReturn(true);
$interfaceA->method('isTrait')->willReturn(false);
$interfaceA->method('isAbstract')->willReturn(false);
Expand All @@ -269,6 +279,7 @@ public function testComplexClass(): void
$interfaceB->method('getShortName')->willReturn('InterfaceB');
$interfaceB->method('getName')->willReturn('vendor\library\TestStuff\InterfaceB');
$interfaceB->method('getDocComment')->willReturn(false);
$interfaceB->method('getAttributes')->willReturn([]);
$interfaceB->method('isInterface')->willReturn(true);
$interfaceB->method('isTrait')->willReturn(false);
$interfaceB->method('isAbstract')->willReturn(false);
Expand All @@ -294,6 +305,7 @@ public function testComplexClass(): void
*/
EOT
);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(false);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down Expand Up @@ -340,6 +352,7 @@ public function testComplexInterface(): void
$interfaceFromInterface->method('getShortName')->willReturn('SomeOtherInterface');
$interfaceFromInterface->method('getName')->willReturn('vendor\library\TestStuff\SomeOtherInterface');
$interfaceFromInterface->method('getDocComment')->willReturn(false);
$interfaceFromInterface->method('getAttributes')->willReturn([]);
$interfaceFromInterface->method('isInterface')->willReturn(true);
$interfaceFromInterface->method('isTrait')->willReturn(false);
$interfaceFromInterface->method('isAbstract')->willReturn(false);
Expand All @@ -355,6 +368,7 @@ public function testComplexInterface(): void
$interfaceA->method('getShortName')->willReturn('InterfaceA');
$interfaceA->method('getName')->willReturn('vendor\library\TestStuff\InterfaceA');
$interfaceA->method('getDocComment')->willReturn(false);
$interfaceA->method('getAttributes')->willReturn([]);
$interfaceA->method('isInterface')->willReturn(true);
$interfaceA->method('isTrait')->willReturn(false);
$interfaceA->method('isAbstract')->willReturn(false);
Expand All @@ -372,6 +386,7 @@ public function testComplexInterface(): void
$interfaceB->method('getShortName')->willReturn('InterfaceB');
$interfaceB->method('getName')->willReturn('vendor\library\TestStuff\InterfaceB');
$interfaceB->method('getDocComment')->willReturn(false);
$interfaceB->method('getAttributes')->willReturn([]);
$interfaceB->method('isInterface')->willReturn(true);
$interfaceB->method('isTrait')->willReturn(false);
$interfaceB->method('isAbstract')->willReturn(false);
Expand All @@ -397,6 +412,7 @@ public function testComplexInterface(): void
*/
EOT
);
$reflectionClass->method('getAttributes')->willReturn([]);
$reflectionClass->method('isInterface')->willReturn(true);
$reflectionClass->method('isTrait')->willReturn(false);
$reflectionClass->method('isAbstract')->willReturn(false);
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Formatter/MethodFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ protected function createReflectionMethodMock(
'hasReturnType',
'getReturnType',
'getDocComment',
'getAttributes',
'isAbstract',
'isFinal',
'isPublic',
Expand Down Expand Up @@ -134,6 +135,7 @@ protected function createReflectionMethodMock(

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

return $result;
}
Expand Down

0 comments on commit 7c92739

Please sign in to comment.