function UrlGeneratorTest::testGenerateWithPathProcessorChangingOptions

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testGenerateWithPathProcessorChangingOptions()
  2. 11.x core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testGenerateWithPathProcessorChangingOptions()

@covers \Drupal\Core\Routing\UrlGenerator::generateFromRoute

Note: We use absolute covers to let \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest work.

File

core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php, line 513

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testGenerateWithPathProcessorChangingOptions() {
    $path_processor = $this->createMock(OutboundPathProcessorInterface::CLASS);
    $path_processor->expects($this->atLeastOnce())
        ->method('processOutbound')
        ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
        $options['query'] = [
            'zoo' => 5,
        ];
        $options['fragment'] = 'foo';
        return $path;
    });
    $this->processorManager
        ->addOutbound($path_processor);
    $options = [];
    $this->assertGenerateFromRoute('test_2', [
        'narf' => 5,
    ], $options, '/goodbye/cruel/world?zoo=5#foo', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.