public function LinkGeneratorTest::testGenerateUrlWithQuotes in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php \Drupal\Tests\Core\Utility\LinkGeneratorTest::testGenerateUrlWithQuotes()
Tests the generate() method with a url containing double quotes.
@covers ::generate
File
- core/
tests/ Drupal/ Tests/ Core/ Utility/ LinkGeneratorTest.php, line 196 - Contains \Drupal\Tests\Core\Utility\LinkGeneratorTest.
Class
- LinkGeneratorTest
- @coversDefaultClass \Drupal\Core\Utility\LinkGenerator @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public function testGenerateUrlWithQuotes() {
$this->urlAssembler
->expects($this
->once())
->method('assemble')
->with('base:example', array(
'query' => array(
'foo' => '"bar"',
'zoo' => 'baz',
),
) + $this->defaultOptions)
->willReturn((new GeneratedUrl())
->setGeneratedUrl('/example?foo=%22bar%22&zoo=baz'));
$path_validator = $this
->getMock('Drupal\\Core\\Path\\PathValidatorInterface');
$container_builder = new ContainerBuilder();
$container_builder
->set('path.validator', $path_validator);
\Drupal::setContainer($container_builder);
$path = '/example?foo="bar"&zoo=baz';
$url = Url::fromUserInput($path);
$url
->setUrlGenerator($this->urlGenerator);
$url
->setUnroutedUrlAssembler($this->urlAssembler);
$result = $this->linkGenerator
->generate('Drupal', $url);
$this
->assertLink(array(
'attributes' => array(
'href' => '/example?foo=%22bar%22&zoo=baz',
),
'content' => 'Drupal',
), $result, 1);
}