function FieldPluginBaseTest::setUpUrlIntegrationServices

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUpUrlIntegrationServices()
  2. 10 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUpUrlIntegrationServices()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUpUrlIntegrationServices()

Sets up the unrouted URL assembler and the link generator.

6 calls to FieldPluginBaseTest::setUpUrlIntegrationServices()
FieldPluginBaseTest::testRenderAsExternalLinkWithPathAndTokens in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Tests rendering of a link with a path and options.
FieldPluginBaseTest::testRenderAsLinkWithoutPath in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Tests rendering as a link without a path.
FieldPluginBaseTest::testRenderAsLinkWithPathAndOptions in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Tests rendering of a link with a path and options.
FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Tests rendering of a link with a path and options.
FieldPluginBaseTest::testRenderAsLinkWithUrlAndOptions in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Tests link rendering with a URL and options.

... See full list

File

core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php, line 175

Class

FieldPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\field\FieldPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

protected function setUpUrlIntegrationServices() {
    $this->pathProcessor = $this->createMock('Drupal\\Core\\PathProcessor\\OutboundPathProcessorInterface');
    $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);
    \Drupal::getContainer()->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
    $this->linkGenerator = new LinkGenerator($this->urlGenerator, $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface'), $this->renderer);
    $this->renderer
        ->method('render')
        ->willReturnCallback(function (&$elements, $is_root_call = FALSE) {
        // Mock the ability to theme links
        $link = $this->linkGenerator
            ->generate($elements['#title'], $elements['#url']);
        if (isset($elements['#prefix'])) {
            $link = $elements['#prefix'] . $link;
        }
        if (isset($elements['#suffix'])) {
            $link = $link . $elements['#suffix'];
        }
        return Markup::create($link);
    });
}

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