tests/phpunit: fill in some phpstan types

This commit is contained in:
Dylan K. Taylor 2020-02-07 18:34:57 +00:00
parent 091873ca51
commit 95896eb911
2 changed files with 19 additions and 0 deletions

View File

@ -40,6 +40,10 @@ class HandlerListManagerTest extends TestCase{
$this->resolveParentFunc = (new \ReflectionMethod(HandlerListManager::class, 'resolveNearestHandleableParent'))->getClosure();
}
/**
* @return \Generator|mixed[][]
* @phpstan-return \Generator<int, array{\ReflectionClass<Event>, bool, string}, void, void>
*/
public function isValidClassProvider() : \Generator{
yield [new \ReflectionClass(Event::class), false, "event base should not be handleable"];
yield [new \ReflectionClass(TestConcreteEvent::class), true, ""];
@ -53,11 +57,16 @@ class HandlerListManagerTest extends TestCase{
* @param \ReflectionClass $class
* @param bool $isValid
* @param string $reason
* @phpstan-param \ReflectionClass<Event> $class
*/
public function testIsValidClass(\ReflectionClass $class, bool $isValid, string $reason) : void{
self::assertSame($isValid, ($this->isValidFunc)($class), $reason);
}
/**
* @return \Generator|\ReflectionClass[][]
* @phpstan-return \Generator<int, array{\ReflectionClass<Event>, \ReflectionClass<Event>|null}, void, void>
*/
public function resolveParentClassProvider() : \Generator{
yield [new \ReflectionClass(TestConcreteExtendsAllowHandleEvent::class), new \ReflectionClass(TestAbstractAllowHandleEvent::class)];
yield [new \ReflectionClass(TestConcreteEvent::class), null];
@ -70,6 +79,8 @@ class HandlerListManagerTest extends TestCase{
*
* @param \ReflectionClass $class
* @param \ReflectionClass|null $expect
* @phpstan-param \ReflectionClass<Event> $class
* @phpstan-param \ReflectionClass<Event>|null $expect
*/
public function testResolveParentClass(\ReflectionClass $class, ?\ReflectionClass $expect) : void{
if($expect === null){

View File

@ -27,6 +27,10 @@ use PHPUnit\Framework\TestCase;
class ApiVersionTest extends TestCase{
/**
* @return \Generator|mixed[][]
* @phpstan-return \Generator<int, array{string, string, bool}, void, void>
*/
public function compatibleApiProvider() : \Generator{
yield ["3.0.0", "3.0.0", true];
yield ["3.1.0", "3.0.0", true];
@ -53,6 +57,10 @@ class ApiVersionTest extends TestCase{
self::assertSame($expected, ApiVersion::isCompatible($myVersion, [$wantVersion]), "my version: $myVersion, their version: $wantVersion, expect " . ($expected ? "yes" : "no"));
}
/**
* @return mixed[][][]
* @phpstan-return \Generator<int, array{list<string>, list<string>}, void, void>
*/
public function ambiguousVersionsProvider() : \Generator{
yield [["3.0.0"], []];
yield [["3.0.0", "3.0.1"], ["3.0.0", "3.0.1"]];