Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / tests / src / Functional / UnsavedPreviewTest.php
1 <?php
2
3 namespace Drupal\Tests\views_ui\Functional;
4
5 /**
6  * Tests covering Preview of unsaved Views.
7  *
8  * @group views_ui
9  */
10 class UnsavedPreviewTest extends UITestBase {
11
12   /**
13     * Views used by this test.
14     *
15     * @var array
16     */
17   public static $testViews = ['content'];
18
19   /**
20    * An admin user with the 'administer views' permission.
21    *
22    * @var \Drupal\user\UserInterface
23    */
24   protected $adminUser;
25
26   /**
27    * {@inheritdoc}
28    */
29   public static $modules = ['node', 'views_ui'];
30
31   /**
32    * Sets up a Drupal site for running functional and integration tests.
33    */
34   protected function setUp($import_test_views = TRUE) {
35     parent::setUp(FALSE);
36
37     $this->adminUser = $this->drupalCreateUser(['administer views']);
38     $this->drupalLogin($this->adminUser);
39   }
40
41   /**
42    * Tests previews of unsaved new page displays.
43    */
44   public function testUnsavedPageDisplayPreview() {
45     $this->drupalCreateContentType(['type' => 'page']);
46     for ($i = 0; $i < 5; $i++) {
47       $this->drupalCreateNode();
48     }
49
50     $this->drupalGet('admin/structure/views/view/content');
51     $this->assertResponse(200);
52
53     $this->drupalPostForm(NULL, [], t('Add Page'));
54     $this->assertResponse(200);
55
56     $this->drupalGet('admin/structure/views/nojs/display/content/page_2/path');
57     $this->assertResponse(200);
58
59     $this->drupalPostForm(NULL, ['path' => 'foobarbaz'], t('Apply'));
60     $this->assertResponse(200);
61
62     $this->drupalPostForm(NULL, [], t('Update preview'));
63     $this->assertResponse(200);
64     $this->assertText(t('This display has no path'));
65
66     $this->drupalGet('admin/structure/views/view/content/edit/page_2');
67     $this->assertResponse(200);
68
69     $this->drupalPostForm(NULL, [], t('Save'));
70     $this->assertResponse(200);
71
72     $this->drupalPostForm(NULL, [], t('Update preview'));
73     $this->assertResponse(200);
74     $this->assertLinkByHref('foobarbaz');
75   }
76
77 }