3 namespace Drupal\Tests\node\Functional\Views;
5 use Drupal\views\Views;
8 * Tests the node row plugin.
12 class PathPluginTest extends NodeTestBase {
19 public static $modules = ['node'];
22 * Views used by this test.
26 public static $testViews = ['test_node_path_plugin'];
29 * Contains all nodes used by this test.
38 protected function setUp($import_test_views = TRUE) {
39 parent::setUp($import_test_views);
41 $this->drupalCreateContentType(['type' => 'article']);
44 for ($i = 0; $i < 2; $i++) {
45 $this->nodes[] = $this->drupalCreateNode(
50 'value' => $this->randomMachineName(42),
51 'format' => filter_default_format(),
52 'summary' => $this->randomMachineName(),
61 * Tests the node path plugin.
63 public function testPathPlugin() {
64 /** @var \Drupal\Core\Render\RendererInterface $renderer */
65 $renderer = $this->container->get('renderer');
66 $view = Views::getView('test_node_path_plugin');
68 $view->setDisplay('page_1');
70 $view->rowPlugin->options['view_mode'] = 'full';
72 // Test with view_mode full.
73 $output = $view->preview();
74 $output = $renderer->renderRoot($output);
75 foreach ($this->nodes as $node) {
76 $this->assertTrue(strpos($output, 'This is <strong>not escaped</strong> and this is ' . $node->link('the link')) !== FALSE, 'Make sure path field rewriting is not escaped.');