You are here

public function UnsavedPreviewTest::testUnsavedPageDisplayPreview in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php \Drupal\Tests\views_ui\Functional\UnsavedPreviewTest::testUnsavedPageDisplayPreview()
  2. 10 core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php \Drupal\Tests\views_ui\Functional\UnsavedPreviewTest::testUnsavedPageDisplayPreview()

Tests previews of unsaved new page displays.

File

core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php, line 49

Class

UnsavedPreviewTest
Tests covering Preview of unsaved Views.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testUnsavedPageDisplayPreview() {
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);
  for ($i = 0; $i < 5; $i++) {
    $this
      ->drupalCreateNode();
  }
  $this
    ->drupalGet('admin/structure/views/view/content');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [], t('Add Page'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet('admin/structure/views/nojs/display/content/page_2/path');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [
    'path' => 'foobarbaz',
  ], t('Apply'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [], t('Update preview'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertText(t('This display has no path'));
  $this
    ->drupalGet('admin/structure/views/view/content/edit/page_2');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [], t('Save'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalPostForm(NULL, [], t('Update preview'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertLinkByHref('foobarbaz');
}