mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
tests/phpunit: fill in some phpstan types
This commit is contained in:
parent
091873ca51
commit
95896eb911
@ -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){
|
||||
|
@ -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"]];
|
||||
|
Loading…
x
Reference in New Issue
Block a user