function RowPluginTest::testRowPlugin
Tests the node row plugin.
File
-
core/
modules/ node/ tests/ src/ Kernel/ Views/ RowPluginTest.php, line 99
Class
- RowPluginTest
- Tests the node row plugin.
Namespace
Drupal\Tests\node\Kernel\ViewsCode
public function testRowPlugin() : void {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container
->get('renderer');
$view = Views::getView('test_node_row_plugin');
$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($node->body->value, $output, 'Make sure the full text appears in the output of the view.');
}
// Test with teasers.
$view->rowPlugin->options['view_mode'] = 'teaser';
$output = $view->preview();
$output = (string) $renderer->renderRoot($output);
foreach ($this->nodes as $node) {
// Using 22 because <p> is being included.
$this->assertStringNotContainsString(substr($node->body->value, 22), $output);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.