From 1a27fbc56c5ab55d782969669c4fc097cc166786 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 30 Aug 2023 16:23:55 +0100 Subject: [PATCH] Add native param types in tests Signed-off-by: Kamil Tekiela --- tests/Components/GroupKeywordTest.php | 2 +- tests/Lexer/ContextTest.php | 3 +-- tests/TestCase.php | 2 +- tests/Utils/CLITest.php | 12 ++++++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/Components/GroupKeywordTest.php b/tests/Components/GroupKeywordTest.php index 838e725c..3001ac6a 100644 --- a/tests/Components/GroupKeywordTest.php +++ b/tests/Components/GroupKeywordTest.php @@ -53,7 +53,7 @@ public static function provideExpressions(): Generator /** @param GroupKeyword|array $component */ #[DataProvider('provideExpressions')] - public function testBuild($component, string $expected): void + public function testBuild(GroupKeyword|array $component, string $expected): void { if (is_array($component)) { $this->assertSame($expected, GroupKeyword::buildAll($component)); diff --git a/tests/Lexer/ContextTest.php b/tests/Lexer/ContextTest.php index ec20e684..2b34df8a 100644 --- a/tests/Lexer/ContextTest.php +++ b/tests/Lexer/ContextTest.php @@ -117,9 +117,8 @@ public function testLoadError(): void $this->assertFalse(Context::load('Foo')); } - /** @param int|string $mode */ #[DataProvider('providerForTestMode')] - public function testMode($mode, int $expected): void + public function testMode(int|string $mode, int $expected): void { Context::setMode($mode); $this->assertSame($expected, Context::getMode()); diff --git a/tests/TestCase.php b/tests/TestCase.php index 45f14c31..e4082898 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -59,7 +59,7 @@ public function getTokensList(string $query): TokensList * : list * ) */ - public function getErrorsAsArray($obj): array + public function getErrorsAsArray(Lexer|Parser $obj): array { $ret = []; if ($obj instanceof Lexer) { diff --git a/tests/Utils/CLITest.php b/tests/Utils/CLITest.php index 6f77ce56..fef287ca 100644 --- a/tests/Utils/CLITest.php +++ b/tests/Utils/CLITest.php @@ -50,7 +50,7 @@ public function testGetopt(): void /** @param array|false $getopt */ #[DataProvider('highlightParamsProvider')] - public function testRunHighlight($getopt, string $output, int $result): void + public function testRunHighlight(array|false $getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); $this->expectOutputString($output); @@ -122,7 +122,7 @@ public static function highlightParamsProvider(): array /** @param array|false $getopt */ #[DataProvider('highlightParamsStdInProvider')] - public function testRunHighlightStdIn(string $input, $getopt, string $output, int $result): void + public function testRunHighlightStdIn(string $input, array|false $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); $this->expectOutputString($output); @@ -187,7 +187,7 @@ public static function highlightParamsStdInProvider(): array /** @param array|false $getopt */ #[DataProvider('lintParamsStdInProvider')] - public function testRunLintFromStdIn(string $input, $getopt, string $output, int $result): void + public function testRunLintFromStdIn(string $input, array|false $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); $this->expectOutputString($output); @@ -249,7 +249,7 @@ public static function lintParamsStdInProvider(): array /** @param array|false $getopt */ #[DataProvider('lintParamsProvider')] - public function testRunLint($getopt, string $output, int $result): void + public function testRunLint(array|false $getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); $this->expectOutputString($output); @@ -313,7 +313,7 @@ public static function lintParamsProvider(): array /** @param array|false $getopt */ #[DataProvider('tokenizeParamsProvider')] - public function testRunTokenize($getopt, string $output, int $result): void + public function testRunTokenize(array|false $getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); $this->expectOutputString($output); @@ -365,7 +365,7 @@ public static function tokenizeParamsProvider(): array /** @param array|false $getopt */ #[DataProvider('tokenizeParamsStdInProvider')] - public function testRunTokenizeStdIn(string $input, $getopt, string $output, int $result): void + public function testRunTokenizeStdIn(string $input, array|false $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); $this->expectOutputString($output);