function FieldPluginBaseTest::setUpUrlIntegrationServices

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUpUrlIntegrationServices()
  2. 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest::setUpUrlIntegrationServices()
  3. 10 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 172

Class

FieldPluginBaseTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21field%21FieldPluginBase.php/class/FieldPluginBase/11.x" title="Base class for views fields." class="local">\Drupal\views\Plugin\views\field\FieldPluginBase</a> @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.