public function ViewElementTest::testViewElementEmbed in Drupal 10
Same name in this branch
- 10 core/modules/views/tests/src/Functional/ViewElementTest.php \Drupal\Tests\views\Functional\ViewElementTest::testViewElementEmbed()
- 10 core/modules/views/tests/src/Kernel/ViewElementTest.php \Drupal\Tests\views\Kernel\ViewElementTest::testViewElementEmbed()
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/ViewElementTest.php \Drupal\Tests\views\Functional\ViewElementTest::testViewElementEmbed()
- 9 core/modules/views/tests/src/Functional/ViewElementTest.php \Drupal\Tests\views\Functional\ViewElementTest::testViewElementEmbed()
Tests the rendered output and form output of a view element, using the embed display plugin.
File
- core/
modules/ views/ tests/ src/ Functional/ ViewElementTest.php, line 79
Class
- ViewElementTest
- Tests the view render element.
Namespace
Drupal\Tests\views\FunctionalCode
public function testViewElementEmbed() {
$view = Views::getView('test_view_embed');
$view
->setDisplay();
// Test a form.
$this
->drupalGet('views_test_data_element_embed_form');
// Verify that the view container has been found on the form.
$this
->assertSession()
->elementExists('xpath', '//div[@class="views-element-container js-form-wrapper form-wrapper"]');
// Verify that the view content has been found on the form.
$this
->assertSession()
->elementExists('xpath', '//div[@class="view-content"]');
// There should be 5 rows in the results.
$this
->assertSession()
->elementsCount('xpath', '//div[@class="view-content"]/div', 5);
// Add an argument and save the view.
$view->displayHandlers
->get('default')
->overrideOption('arguments', [
'age' => [
'default_action' => 'ignore',
'title' => '',
'default_argument_type' => 'fixed',
'validate' => [
'type' => 'none',
'fail' => 'not found',
],
'break_phrase' => FALSE,
'not' => FALSE,
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'plugin_id' => 'numeric',
],
]);
$view
->save();
// Test that the form has the same expected result.
$this
->drupalGet('views_test_data_element_embed_form');
$this
->assertSession()
->elementsCount('xpath', '//div[@class="view-content"]/div', 1);
}