From e42e1fcb86806c6fb6af97f5035fcc50408ea48b Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 25 Dec 2024 14:56:21 +0100 Subject: [PATCH] Resolve new PHPStan errors --- etc/qa/phpstan.neon | 5 ----- src/TestCase.php | 13 +++++-------- tests/TestCaseTest.php | 10 +++++++++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/etc/qa/phpstan.neon b/etc/qa/phpstan.neon index 14f45459..01fee972 100644 --- a/etc/qa/phpstan.neon +++ b/etc/qa/phpstan.neon @@ -1,7 +1,2 @@ -parameters: - ignoreErrors: - - '#Method WyriHaximus\\TestUtilities\\TestCase::setUp\(\) is not final, but since the containing class is abstract, it should be.#' - - '#Method WyriHaximus\\TestUtilities\\TestCase::tearDown\(\) is not final, but since the containing class is abstract, it should be.#' - includes: - phar://phpstan.phar/conf/bleedingEdge.neon diff --git a/src/TestCase.php b/src/TestCase.php index 72a13654..055f01e7 100644 --- a/src/TestCase.php +++ b/src/TestCase.php @@ -33,7 +33,6 @@ abstract class TestCase extends PHPUnitTestCase use MockeryPHPUnitIntegration; public const string WINDOWS_TEMP_DIR_PREFIX = 'C:\\t\\'; - public const int DEFAULT_AWAIT_TIMEOUT = 60; public const int WIN_START = 0; public const int WIN_END = 2; public const int USLEEP = 50; @@ -68,13 +67,11 @@ protected function tearDown(): void $this->rmdir($this->baseTmpDir); } - /** @return array> */ - final public static function provideTrueFalse(): array + /** @return iterable> */ + final public static function provideTrueFalse(): iterable { - return [ - [true], - [false], - ]; + yield 'true' => [true]; + yield 'false' => [false]; } final protected function getSysTempDir(): string @@ -121,7 +118,7 @@ final protected function getRandomNameSpace(): string return $this->tmpNamespace; } - /** @return array */ + /** @return list */ final protected function getFilesInDirectory(string $path): array { $files = []; diff --git a/tests/TestCaseTest.php b/tests/TestCaseTest.php index 13589893..01c0a8ed 100644 --- a/tests/TestCaseTest.php +++ b/tests/TestCaseTest.php @@ -79,11 +79,19 @@ public function testTemporaryDirectoryAndGetFilesInDirectory(string $int): void } /** @dataProvider provideTrueFalse */ - public static function testTrueFalse(bool $bool): void + public function testTrueOrFalse(bool $bool): void { static::assertCount(1, func_get_args()); } + public function testTrueAndFalse(): void + { + static::assertSame( + ['true' => [true], 'false' => [false]], + [...self::provideTrueFalse()], + ); + } + public function testGetSysTempDir(): void { self::assertFileExists($this->getSysTempDir());