From 72af8b049dca3bf19114c599d309be65d8bb99d8 Mon Sep 17 00:00:00 2001 From: Nicolas Reynis Date: Fri, 1 Oct 2021 22:24:26 +0200 Subject: [PATCH] Add type specifying support for classes extending Assert --- .../AssertMethodTypeSpecifyingExtension.php | 2 +- ...ssertMethodTypeSpecifyingExtensionTest.php | 36 +++++++++++++++++++ tests/Type/PHPUnit/data/assert-method.php | 17 +++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php create mode 100644 tests/Type/PHPUnit/data/assert-method.php diff --git a/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php b/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php index 0fb0a3e..6307f24 100644 --- a/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php +++ b/src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php @@ -24,7 +24,7 @@ public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void public function getClass(): string { - return 'PHPUnit\Framework\TestCase'; + return 'PHPUnit\Framework\Assert'; } public function isMethodSupported( diff --git a/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php b/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php new file mode 100644 index 0000000..6f6a1fc --- /dev/null +++ b/tests/Type/PHPUnit/AssertMethodTypeSpecifyingExtensionTest.php @@ -0,0 +1,36 @@ +gatherAssertTypes(__DIR__ . '/data/assert-method.php'); + } + + /** + * @dataProvider dataFileAsserts + * @param string $assertType + * @param string $file + * @param mixed ...$args + */ + public function testFileAsserts( + string $assertType, + string $file, + ...$args + ): void + { + $this->assertFileAsserts($assertType, $file, ...$args); + } + + public static function getAdditionalConfigFiles(): array + { + return [__DIR__ . '/../../../extension.neon']; + } + +} diff --git a/tests/Type/PHPUnit/data/assert-method.php b/tests/Type/PHPUnit/data/assert-method.php new file mode 100644 index 0000000..2f791ed --- /dev/null +++ b/tests/Type/PHPUnit/data/assert-method.php @@ -0,0 +1,17 @@ +assertNotNull($s); + assertType('string', $s); + } + +}