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 functionality when converted to entity link.
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 // The configured deprecated node path plugin should be converted to the
69 // entity link plugin.
70 $field = $view->getHandler('page_1', 'field', 'path');
71 $this->assertEqual('entity_link', $field['plugin_id']);
74 $view->setDisplay('page_1');
76 $view->rowPlugin->options['view_mode'] = 'full';
78 // Test with view_mode full.
79 $output = $view->preview();
80 $output = $renderer->renderRoot($output);
81 foreach ($this->nodes as $node) {
82 $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.');