DisplayFeedTest.php in Drupal 10
File
core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
View source
<?php
namespace Drupal\Tests\views_ui\Functional;
class DisplayFeedTest extends UITestBase {
public static $testViews = [
'test_display_feed',
];
protected static $modules = [
'views_ui',
];
protected $defaultTheme = 'stark';
public function testFeedUI() {
foreach (self::$testViews as $view_name) {
$this
->checkFeedViewUi($view_name);
}
}
protected function checkFeedViewUi($view_name) {
$this
->drupalGet('admin/structure/views');
$this
->assertSession()
->pageTextContains($view_name);
$this
->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays');
$this
->assertSession()
->assertEscaped('<em>Page</em>');
$result = $this
->xpath('//div[@id="edit-displays"]/div');
$options = [];
foreach ($result as $item) {
$input_node = $item
->find('css', 'input');
if ($input_node
->hasAttribute('value')) {
$options[] = $input_node
->getAttribute('value');
}
}
$this
->assertEquals([
'default',
'page',
], $options, 'Make sure all displays appears as expected.');
$this
->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays');
$this
->submitForm([
'displays[page]' => 'page',
], 'Apply');
$this
->assertSession()
->assertEscaped('<em>Page</em>');
$this
->assertSession()
->responseNotContains('<em>Page</em>');
$this
->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
$this
->assertSession()
->elementTextContains('xpath', '//*[@id="views-feed-1-displays"]', 'Page');
$this
->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays');
$this
->submitForm([
'displays[default]' => 'default',
], 'Apply');
$this
->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
$this
->assertSession()
->elementTextContains('xpath', '//*[@id="views-feed-1-displays"]', 'Multiple displays');
}
}