function PathPluginTest::testPathPlugin

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/Views/PathPluginTest.php \Drupal\Tests\node\Functional\Views\PathPluginTest::testPathPlugin()
  2. 8.9.x core/modules/node/tests/src/Functional/Views/PathPluginTest.php \Drupal\Tests\node\Functional\Views\PathPluginTest::testPathPlugin()
  3. 10 core/modules/node/tests/src/Kernel/Views/PathPluginTest.php \Drupal\Tests\node\Kernel\Views\PathPluginTest::testPathPlugin()

Tests the node path plugin functionality when converted to entity link.

File

core/modules/node/tests/src/Kernel/Views/PathPluginTest.php, line 74

Class

PathPluginTest
Tests the node row plugin.

Namespace

Drupal\Tests\node\Kernel\Views

Code

public function testPathPlugin() : void {
    
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container
        ->get('renderer');
    $view = Views::getView('test_node_path_plugin');
    // The configured deprecated node path plugin should be converted to the
    // entity link plugin.
    $field = $view->getHandler('page_1', 'field', 'path');
    $this->assertEquals('entity_link', $field['plugin_id']);
    $view->initDisplay();
    $view->setDisplay('page_1');
    $view->initStyle();
    $view->rowPlugin->options['view_mode'] = 'full';
    // Test with view_mode full.
    $output = $view->preview();
    $output = (string) $renderer->renderRoot($output);
    foreach ($this->nodes as $node) {
        $this->assertStringContainsString('This is <strong>not escaped</strong> and this is ' . $node->toLink('the link')
            ->toString(), $output, 'Make sure path field rewriting is not escaped.');
    }
}

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