/** * @covers ::registerTagHandler * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::create * @uses phpDocumentor\Reflection\DocBlock\Tags\Author */ public function testRegisteringAHandlerForANewTag() { $resolver = m::mock(FqsenResolver::class); $tagFactory = new StandardTagFactory($resolver); $tagFactory->registerTagHandler('my-tag', Author::class); // Assert by trying to create one $tag = $tagFactory->create('@my-tag Mike van Riel <*****@*****.**>'); $this->assertInstanceOf(Author::class, $tag); }
/** * @covers ::create * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService * @uses phpDocumentor\Reflection\Docblock\Description * @uses phpDocumentor\Reflection\Docblock\Tags\Return_ * @uses phpDocumentor\Reflection\Docblock\Tags\BaseTag */ public function testReturntagIsMappedCorrectly() { $context = new Context(''); $descriptionFactory = m::mock(DescriptionFactory::class); $descriptionFactory->shouldReceive('create')->once()->with('', $context)->andReturn(new Description('')); $typeResolver = new TypeResolver(); $tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class)); $tagFactory->addService($descriptionFactory, DescriptionFactory::class); $tagFactory->addService($typeResolver, TypeResolver::class); /** @var Return_ $tag */ $tag = $tagFactory->create('@return mixed', $context); $this->assertInstanceOf(Return_::class, $tag); $this->assertSame('return', $tag->getName()); }