From f8002ca27edebaecc554a543cb1729abe5e35f20 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 26 Nov 2016 06:35:23 +0100 Subject: [PATCH] #6068 hardened test logic to verify that nothing is present after the `|null` in `@var` and `@return` types --- .../Tests/ORM/Tools/EntityGeneratorTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index d243bdbe4..89c073fd2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -1080,17 +1080,25 @@ class */ private function assertPhpDocVarType($type, \ReflectionProperty $property) { - $this->assertEquals(1, preg_match('/@var\s+([^\s]+)/',$property->getDocComment(), $matches)); + $docComment = $property->getDocComment(); + $regex = '/@var\s+([\S]+)$/m'; + + $this->assertRegExp($regex, $docComment); + $this->assertEquals(1, preg_match($regex, $docComment, $matches)); $this->assertEquals($type, $matches[1]); } /** * @param string $type - * @param \ReflectionProperty $method + * @param \ReflectionMethod $method */ private function assertPhpDocReturnType($type, \ReflectionMethod $method) { - $this->assertEquals(1, preg_match('/@return\s+([^\s]+)/', $method->getDocComment(), $matches)); + $docComment = $method->getDocComment(); + $regex = '/@return\s+([\S]+)(\s+.*)$/m'; + + $this->assertRegExp($regex, $docComment); + $this->assertEquals(1, preg_match($regex, $docComment, $matches)); $this->assertEquals($type, $matches[1]); }