Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / src / Tests / DisplayFeedTest.php
1 <?php
2
3 namespace Drupal\views_ui\Tests;
4
5 /**
6  * Tests the UI for feed display plugin.
7  *
8  * @group views_ui
9  * @see \Drupal\views\Plugin\views\display\Feed
10  */
11 class DisplayFeedTest extends UITestBase {
12
13   /**
14    * Views used by this test.
15    *
16    * @var array
17    */
18   public static $testViews = ['test_display_feed', 'test_style_opml'];
19
20   /**
21    * Modules to enable.
22    *
23    * @var array
24    */
25   public static $modules = ['views_ui', 'aggregator'];
26
27   /**
28    * Tests feed display admin UI.
29    */
30   public function testFeedUI() {
31     // Test both RSS and OPML feeds.
32     foreach (self::$testViews as $view_name) {
33       $this->checkFeedViewUi($view_name);
34     }
35   }
36
37   /**
38    * Checks views UI for a specific feed view.
39    *
40    * @param string $view_name
41    *   The view name to check against.
42    */
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
48     // all displays.
49     $this->assertText($view_name);
50
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>');
55
56     // Load all the options of the checkbox.
57     $result = $this->xpath('//div[@id="edit-displays"]/div');
58     $options = [];
59     foreach ($result as $item) {
60       foreach ($item->input->attributes() as $attribute => $value) {
61         if ($attribute == 'value') {
62           $options[] = (string) $value;
63         }
64       }
65     }
66
67     $this->assertEqual($options, ['default', 'page'], 'Make sure all displays appears as expected.');
68
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>');
74
75     $this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
76     $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
77
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');
82   }
83
84 }