You are here

protected function FieldPluginBaseTest::setUpUrlIntegrationServices in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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.

5 calls to FieldPluginBaseTest::setUpUrlIntegrationServices()
FieldPluginBaseTest::testRenderAsLinkWithoutPath in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Test rendering as a link without a path.
FieldPluginBaseTest::testRenderAsLinkWithPathAndOptions in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Test rendering of a link with a path and options.
FieldPluginBaseTest::testRenderAsLinkWithPathAndTokens in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Test 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.
FieldPluginBaseTest::testRenderTrimmedWithMoreLink in core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
Test rendering as a link without a path.

File

core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php, line 172
Contains \Drupal\Tests\views\Unit\Plugin\field\FieldPluginBaseTest.

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
    ->getMock('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
    ->getMock('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);
  });
}