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