3 namespace Drupal\Tests\views_ui\Functional;
6 * Tests the UI for feed display plugin.
9 * @see \Drupal\views\Plugin\views\display\Feed
11 class DisplayFeedTest extends UITestBase {
14 * Views used by this test.
18 public static $testViews = ['test_display_feed', 'test_style_opml'];
25 public static $modules = ['views_ui', 'aggregator'];
28 * Tests feed display admin UI.
30 public function testFeedUI() {
31 // Test both RSS and OPML feeds.
32 foreach (self::$testViews as $view_name) {
33 $this->checkFeedViewUi($view_name);
38 * Checks views UI for a specific feed view.
40 * @param string $view_name
41 * The view name to check against.
43 protected function checkFeedViewUi($view_name) {
44 $this->drupalGet('admin/structure/views');
45 // Verify that the page lists the $view_name view.
46 // Regression test: ViewListBuilder::getDisplayPaths() did not properly
47 // check whether a DisplayPluginCollection was returned in iterating over
49 $this->assertText($view_name);
51 // Check the attach TO interface.
52 $this->drupalGet('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays');
53 // Display labels should be escaped.
54 $this->assertEscaped('<em>Page</em>');
56 // Load all the options of the checkbox.
57 $result = $this->xpath('//div[@id="edit-displays"]/div');
59 foreach ($result as $item) {
60 $input_node = $item->find('css', 'input');
61 if ($input_node->hasAttribute('value')) {
62 $options[] = $input_node->getAttribute('value');
66 $this->assertEqual($options, ['default', 'page'], 'Make sure all displays appears as expected.');
68 // Post and save this and check the output.
69 $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[page]' => 'page'], t('Apply'));
70 // Options summary should be escaped.
71 $this->assertEscaped('<em>Page</em>');
72 $this->assertNoRaw('<em>Page</em>');
74 $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
75 $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
77 // Add the default display, so there should now be multiple displays.
78 $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[default]' => 'default'], t('Apply'));
79 $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
80 $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');