You are here

public function PagePreviewTest::testSimultaneousPreview in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/node/src/Tests/PagePreviewTest.php \Drupal\node\Tests\PagePreviewTest::testSimultaneousPreview()

Checks the node preview accessible for simultaneous node editing.

File

core/modules/node/src/Tests/PagePreviewTest.php, line 307
Contains \Drupal\node\Tests\PagePreviewTest.

Class

PagePreviewTest
Tests the node entity preview functionality.

Namespace

Drupal\node\Tests

Code

public function testSimultaneousPreview() {
  $title_key = 'title[0][value]';
  $node = $this
    ->drupalCreateNode(array());
  $edit = array(
    $title_key => 'New page title',
  );
  $this
    ->drupalPostForm('node/' . $node
    ->id() . '/edit', $edit, t('Preview'));
  $this
    ->assertText($edit[$title_key]);
  $user2 = $this
    ->drupalCreateUser(array(
    'edit any page content',
  ));
  $this
    ->drupalLogin($user2);
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $this
    ->assertFieldByName($title_key, $node
    ->label(), 'No title leaked from previous user.');
  $edit2 = array(
    $title_key => 'Another page title',
  );
  $this
    ->drupalPostForm('node/' . $node
    ->id() . '/edit', $edit2, t('Preview'));
  $this
    ->assertUrl(\Drupal::url('entity.node.preview', [
    'node_preview' => $node
      ->uuid(),
    'view_mode_id' => 'default',
  ], [
    'absolute' => TRUE,
  ]));
  $this
    ->assertText($edit2[$title_key]);
}