Skip to content

Commit

Permalink
Test merged inherited @throws
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 10, 2020
1 parent b803293 commit 9a7ce62
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/InvalidThrowsPhpDocValueRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Rules\PhpDoc;

use PHPStan\Type\FileTypeMapper;
use PHPStan\Type\VerbosityLevel;

/**
* @extends \PHPStan\Testing\RuleTestCase<InvalidThrowsPhpDocValueRule>
Expand Down Expand Up @@ -67,4 +68,45 @@ public function testInheritedPhpDocs(): void
]);
}

public function dataMergeInheritedPhpDocs(): array
{
return [
[
\InvalidThrowsPhpDocMergeInherited\Two::class,
'method',
'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D',
],
[
\InvalidThrowsPhpDocMergeInherited\Three::class,
'method',
'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D',
],
[
\InvalidThrowsPhpDocMergeInherited\Four::class,
'method',
'InvalidThrowsPhpDocMergeInherited\C|InvalidThrowsPhpDocMergeInherited\D',
],
];
}

/**
* @dataProvider dataMergeInheritedPhpDocs
* @param string $className
* @param string $method
* @param string $expectedType
*/
public function testMergeInheritedPhpDocs(
string $className,
string $method,
string $expectedType
): void
{
$reflectionProvider = $this->createBroker();
$reflection = $reflectionProvider->getClass($className);
$method = $reflection->getNativeMethod($method);
$throwsType = $method->getThrowType();
$this->assertNotNull($throwsType);
$this->assertSame($expectedType, $throwsType->describe(VerbosityLevel::precise()));
}

}

0 comments on commit 9a7ce62

Please sign in to comment.