DisplayFeedTest.php in Drupal 8
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',
'test_style_opml',
];
public static $modules = [
'views_ui',
'aggregator',
];
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
->assertText($view_name);
$this
->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays');
$this
->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
->assertEqual($options, [
'default',
'page',
], 'Make sure all displays appears as expected.');
$this
->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', [
'displays[page]' => 'page',
], t('Apply'));
$this
->assertEscaped('<em>Page</em>');
$this
->assertNoRaw('<em>Page</em>');
$this
->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
$this
->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
$this
->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', [
'displays[default]' => 'default',
], t('Apply'));
$this
->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
$this
->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');
}
}