protected function FieldPluginBaseTest::setUpUrlIntegrationServices in Drupal 9
Same name and namespace in other branches
- 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.
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.
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldPluginBaseTest.php, line 175 - 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\fieldCode
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);
});
}