diff --git a/src/DocBlock/Tags/Template.php b/src/DocBlock/Tags/Template.php index e6d9a7e1..cfd6b699 100644 --- a/src/DocBlock/Tags/Template.php +++ b/src/DocBlock/Tags/Template.php @@ -21,7 +21,7 @@ /** * Reflection class for a {@}template tag in a Docblock. */ -final class Template extends TagWithType +final class Template extends BaseTag { /** @var non-empty-string */ private string $templateName; diff --git a/tests/integration/InterpretingDocBlocksTest.php b/tests/integration/InterpretingDocBlocksTest.php index c901f5ca..5c240768 100644 --- a/tests/integration/InterpretingDocBlocksTest.php +++ b/tests/integration/InterpretingDocBlocksTest.php @@ -25,6 +25,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Return_; use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\DocBlock\Tags\Since; +use phpDocumentor\Reflection\DocBlock\Tags\Template; use phpDocumentor\Reflection\PseudoTypes\ConstExpression; use phpDocumentor\Reflection\Types\Array_; use phpDocumentor\Reflection\Types\Compound; @@ -431,4 +432,35 @@ public function testIndentationIsKept(): void $docblock ); } + + public function testProcessTemplateTag(): void + { + $docComment = <<create($docComment); + + self::assertEquals( + [ + new Template( + 'T', + new Object_(new Fqsen('\\Type')), + new Mixed_(), + new Description('this is a description') + ), + new Template( + 'TDefault', + new Object_(new Fqsen('\\Type')), + new Object_(new Fqsen('\\String_')), + new Description('this is a description') + ), + ], + $docblock->getTags() + ); + } } diff --git a/tests/unit/DocBlock/Tags/ExtendsTest.php b/tests/unit/DocBlock/Tags/ExtendsTest.php new file mode 100644 index 00000000..a04f4a82 --- /dev/null +++ b/tests/unit/DocBlock/Tags/ExtendsTest.php @@ -0,0 +1,30 @@ +assertSame('extends', $fixture->getName()); + $this->assertSame($type, $fixture->getType()); + } + + public function testRendersCorrectly(): void + { + $type = new Object_(new Fqsen('\\Type')); + $fixture = new Extends_($type); + $this->assertSame('@extends \\Type', $fixture->render()); + } +} diff --git a/tests/unit/DocBlock/Tags/ImplementsTest.php b/tests/unit/DocBlock/Tags/ImplementsTest.php new file mode 100644 index 00000000..ff24b8fe --- /dev/null +++ b/tests/unit/DocBlock/Tags/ImplementsTest.php @@ -0,0 +1,30 @@ +assertSame('implements', $fixture->getName()); + $this->assertSame($type, $fixture->getType()); + } + + public function testRendersCorrectly(): void + { + $type = new Object_(new Fqsen('\\Type')); + $fixture = new Implements_($type); + $this->assertSame('@implements \\Type', $fixture->render()); + } +} diff --git a/tests/unit/DocBlock/Tags/TemplateExtendsTest.php b/tests/unit/DocBlock/Tags/TemplateExtendsTest.php new file mode 100644 index 00000000..90a2d6bb --- /dev/null +++ b/tests/unit/DocBlock/Tags/TemplateExtendsTest.php @@ -0,0 +1,30 @@ +assertSame('template-extends', $fixture->getName()); + $this->assertSame($type, $fixture->getType()); + } + + public function testRendersCorrectly(): void + { + $type = new Object_(new Fqsen('\\Type')); + $fixture = new TemplateExtends($type); + $this->assertSame('@template-extends \\Type', $fixture->render()); + } +} diff --git a/tests/unit/DocBlock/Tags/TemplateImplementsTest.php b/tests/unit/DocBlock/Tags/TemplateImplementsTest.php new file mode 100644 index 00000000..2e1f319d --- /dev/null +++ b/tests/unit/DocBlock/Tags/TemplateImplementsTest.php @@ -0,0 +1,30 @@ +assertSame('template-implements', $fixture->getName()); + $this->assertSame($type, $fixture->getType()); + } + + public function testRendersCorrectly(): void + { + $type = new Object_(new Fqsen('\\Type')); + $fixture = new TemplateImplements($type); + $this->assertSame('@template-implements \\Type', $fixture->render()); + } +} diff --git a/tests/unit/DocBlock/Tags/TemplateTest.php b/tests/unit/DocBlock/Tags/TemplateTest.php new file mode 100644 index 00000000..71540533 --- /dev/null +++ b/tests/unit/DocBlock/Tags/TemplateTest.php @@ -0,0 +1,38 @@ + + */ +final class TemplateTest extends TestCase +{ + /** + * @covers ::__construct + * @covers ::getTemplateName + * @covers ::getBound + * @covers ::getDefault + */ + public function testTemplateCreatedCorrectly(): void + { + $fixture = new Template('myTemplate', new String_(), new Mixed_(), new Description('')); + $this->assertSame('template', $fixture->getName()); + $this->assertSame('myTemplate', $fixture->getTemplateName()); + $this->assertEquals(new String_(), $fixture->getBound()); + $this->assertEquals(new Mixed_(), $fixture->getDefault()); + } + + public function testRendersCorrectly(): void + { + $fixture = new Template('myTemplate', new String_(), null, new Description('')); + $this->assertSame('@template myTemplate of string', $fixture->render()); + } +}