/**
* Tests the rendered output and form output of a view element.
*/
public function testViewElement() { /** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer =
$this->container->
get('renderer'
);
$view = Views::
getView('test_view_embed'
);
// Get the render array, #embed must be FALSE since this is the default
// display.
$render =
$view->
buildRenderable();
$this->
assertFalse($render['#embed'
]);
$this->
setRawContent($renderer->
renderRoot($render));
$xpath =
$this->
xpath('//div[@class="views-element-container"]'
);
$this->
assertNotEmpty($xpath, 'The view container has been found in the rendered output.'
);
// There should be 5 rows in the results.
$xpath =
$this->
xpath('//div[@class="views-row"]'
);
$this->
assertCount(5,
$xpath);
// Add an argument and save the view.