diff --git a/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php b/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php index 6a684d3..d4ec8fb 100644 --- a/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php +++ b/src/Type/PHPUnit/Assert/AssertFunctionTypeSpecifyingExtension.php @@ -29,7 +29,7 @@ public function isFunctionSupported( ): bool { return AssertTypeSpecifyingExtensionHelper::isSupported( - $functionReflection->getName(), + $this->trimName($functionReflection->getName()), $node->args ); } @@ -44,9 +44,19 @@ public function specifyTypes( return AssertTypeSpecifyingExtensionHelper::specifyTypes( $this->typeSpecifier, $scope, - $functionReflection->getName(), + $this->trimName($functionReflection->getName()), $node->args ); } + private function trimName(string $functionName): string + { + $prefix = 'PHPUnit\\Framework\\'; + if (strpos($functionName, $prefix) === 0) { + return substr($functionName, strlen($prefix)); + } + + return $functionName; + } + } diff --git a/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php new file mode 100644 index 0000000..e1984cf --- /dev/null +++ b/tests/Type/PHPUnit/AssertFunctionTypeSpecifyingExtensionTest.php @@ -0,0 +1,36 @@ +gatherAssertTypes(__DIR__ . '/data/assert-function.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-function.php b/tests/Type/PHPUnit/data/assert-function.php new file mode 100644 index 0000000..5c1cc96 --- /dev/null +++ b/tests/Type/PHPUnit/data/assert-function.php @@ -0,0 +1,20 @@ +