function PreviewTest::testPreviewContextual
Same name in other branches
- 8.9.x core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewContextual()
- 10 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewContextual()
- 11.x core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewContextual()
Tests contextual links in the preview form.
File
-
core/
modules/ views_ui/ tests/ src/ Functional/ PreviewTest.php, line 33
Class
- PreviewTest
- Tests the UI preview functionality.
Namespace
Drupal\Tests\views_ui\FunctionalCode
public function testPreviewContextual() {
\Drupal::service('module_installer')->install([
'contextual',
]);
$this->resetAll();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertSession()
->statusCodeEquals(200);
$this->submitForm($edit = [], 'Update preview');
// Verify that the contextual link to add a new field is shown.
$selector = $this->assertSession()
->buildXPathQuery('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li/a[contains(@href, :href)]', [
':ul-class' => 'contextual-links',
':href' => '/admin/structure/views/nojs/add-handler/test_preview/default/filter',
]);
$this->assertSession()
->elementsCount('xpath', $selector, 1);
$this->submitForm([
'view_args' => '100',
], 'Update preview');
// Test that area text and exposed filters are present and rendered.
$this->assertSession()
->fieldExists('id');
$this->assertSession()
->pageTextContains('Test header text');
$this->assertSession()
->pageTextContains('Test footer text');
$this->assertSession()
->pageTextContains('Test empty text');
$this->submitForm([
'view_args' => '0',
], 'Update preview');
// Test that area text and exposed filters are present and rendered.
$this->assertSession()
->fieldExists('id');
$this->assertSession()
->pageTextContains('Test header text');
$this->assertSession()
->pageTextContains('Test footer text');
$this->assertSession()
->pageTextContains('Test empty text');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.