3 namespace Drupal\views_ui\Tests;
5 use Drupal\views\Tests\ViewTestBase;
8 * Tests covering Preview of unsaved Views.
12 class UnsavedPreviewTest extends ViewTestBase {
15 * Views used by this test.
19 public static $testViews = ['content'];
22 * An admin user with the 'administer views' permission.
24 * @var \Drupal\user\UserInterface
31 public static $modules = ['node', 'views_ui'];
34 * Sets up a Drupal site for running functional and integration tests.
36 protected function setUp() {
39 $this->adminUser = $this->drupalCreateUser(['administer views']);
40 $this->drupalLogin($this->adminUser);
44 * Tests previews of unsaved new page displays.
46 public function testUnsavedPageDisplayPreview() {
47 $this->drupalCreateContentType(['type' => 'page']);
48 for ($i = 0; $i < 5; $i++) {
49 $this->drupalCreateNode();
52 $this->drupalGet('admin/structure/views/view/content');
53 $this->assertResponse(200);
55 $this->drupalPostForm(NULL, [], t('Add Page'));
56 $this->assertResponse(200);
58 $this->drupalGet('admin/structure/views/nojs/display/content/page_2/path');
59 $this->assertResponse(200);
61 $this->drupalPostForm(NULL, ['path' => 'foobarbaz'], t('Apply'));
62 $this->assertResponse(200);
64 $this->drupalPostForm(NULL, [], t('Update preview'));
65 $this->assertResponse(200);
66 $this->assertText(t('This display has no path'));
68 $this->drupalGet('admin/structure/views/view/content/edit/page_2');
69 $this->assertResponse(200);
71 $this->drupalPostForm(NULL, [], t('Save'));
72 $this->assertResponse(200);
74 $this->drupalPostForm(NULL, [], t('Update preview'));
75 $this->assertResponse(200);
76 $this->assertLinkByHref('foobarbaz');