From 98e82e39fa7c9e226ef3c32d4af5514a12e5db8f Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Sun, 5 Sep 2021 18:57:50 +0000 Subject: [PATCH] Tests: add a case to cover issue #298 --- tests/unit/DocBlock/Tags/InvalidTagTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/DocBlock/Tags/InvalidTagTest.php b/tests/unit/DocBlock/Tags/InvalidTagTest.php index 2de2d06..cb25754 100644 --- a/tests/unit/DocBlock/Tags/InvalidTagTest.php +++ b/tests/unit/DocBlock/Tags/InvalidTagTest.php @@ -108,4 +108,19 @@ final class InvalidTagTest extends TestCase $function(fopen(__FILE__, 'r')); } + + public function testCreationWithErrorFromEval(): void + { + $builder = static function (): InvalidArgumentException { + return new InvalidArgumentException(); + }; + + $exception = eval('return $builder();'); + $tag = InvalidTag::create('Body', 'name')->withError($exception); + + self::assertSame('name', $tag->getName()); + self::assertSame('@name Body', $tag->render()); + self::assertSame('Body', (string) $tag); + self::assertSame($exception, $tag->getException()); + } }