3 namespace Drupal\views_ui\Tests;
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 foreach ($item->input->attributes() as $attribute => $value) {
61 if ($attribute == 'value') {
62 $options[] = (string) $value;
67 $this->assertEqual($options, ['default', 'page'], 'Make sure all displays appears as expected.');
69 // Post and save this and check the output.
70 $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[page]' => 'page'], t('Apply'));
71 // Options summary should be escaped.
72 $this->assertEscaped('<em>Page</em>');
73 $this->assertNoRaw('<em>Page</em>');
75 $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
76 $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
78 // Add the default display, so there should now be multiple displays.
79 $this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[default]' => 'default'], t('Apply'));
80 $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
81 $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');