createMock(Parser::class); $environment = $this->createMock(Environment::class); $parser->expects(self::once()) ->method('getEnvironment') ->willReturn($environment); $environment->expects(self::once()) ->method('generateUrl') ->with($url) ->willReturn($url); $configuration = new Configuration(); $templateRenderer = $configuration->getTemplateRenderer(); $span = new SpanNode($parser, 'span'); $spanRenderer = new SpanNodeRenderer($environment, $span, $templateRenderer); self::assertSame( $expectedLink, $spanRenderer->link($url, $title, $attributes) ); } /** * @return array, * expectedLink: string * }> */ public function linkProvider(): array { return [ 'no attributes #1' => [ 'url' => '#', 'title' => 'link', 'attributes' => [], 'expectedLink' => 'link', ], 'no attributes #2' => [ 'url' => '/url?foo=bar&bar=foo', 'title' => 'link', 'attributes' => [], 'expectedLink' => 'link', ], 'no attributes #3' => [ 'url' => 'https://www.doctrine-project.org/', 'title' => 'link', 'attributes' => [], 'expectedLink' => 'link', ], 'with attributes #1' => [ 'url' => '/url', 'title' => 'link', 'attributes' => ['class' => 'foo bar'], 'expectedLink' => 'link', ], 'with attributes #2' => [ 'url' => '/url', 'title' => 'link', 'attributes' => ['class' => 'foo <>bar'], 'expectedLink' => 'link', ], 'with attributes #3' => [ 'url' => '/url', 'title' => 'link', 'attributes' => ['class' => 'foo bar', 'data-id' => '123456'], 'expectedLink' => 'link', ], ]; } }