From 5861b0498a2ebcde81e5e1197adb77f04eb8ac8f Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Sat, 15 Apr 2023 10:45:51 +0200 Subject: [PATCH] fix comments in dokblocks --- src/Factories/Annotations/TestDox.php | 12 +++++++++++- tests/Unit/TestName.php | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Factories/Annotations/TestDox.php b/src/Factories/Annotations/TestDox.php index 227e2f7a..83e12d60 100644 --- a/src/Factories/Annotations/TestDox.php +++ b/src/Factories/Annotations/TestDox.php @@ -14,7 +14,17 @@ final class TestDox implements AddsAnnotations */ public function __invoke(TestCaseMethodFactory $method, array $annotations): array { - $annotations[] = "@testdox $method->description"; + /* + * escapes docblock according to + * https://manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.desc + * + * note: '@' escaping is not needed as it cannot be the first character of the line (it always starts with @testdox + */ + + assert($method->description !== null); + $methodDescription = str_replace('*/', '{@*}', $method->description); + + $annotations[] = "@testdox $methodDescription"; return $annotations; } diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index 0f0fecfe..7723837b 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -61,6 +61,7 @@ $names = [ 'Німеччина' => '__pest_evaluable_Німеччина', 'Nam Định' => '__pest_evaluable_Nam_Định', '呼和浩特' => '__pest_evaluable_呼和浩特', + 'test /** with comment */ should do' => '__pest_evaluable_test_____with_comment____should_do', ]; foreach ($names as $name => $methodName) { @@ -68,5 +69,6 @@ foreach ($names as $name => $methodName) { ->expect(fn () => static::getLatestPrintableTestCaseMethodName()) ->toBe($name) ->and(fn () => $this->name()) - ->toBe($methodName); + ->toBe($methodName) + ->only(); }