Commit bdbd7d3b authored by webchick's avatar webchick

Issue #2535792 by nlisgo, larowlan, BiigNiick: Preview feature broken if requested twice

parent 1787b905
......@@ -88,7 +88,7 @@ public function form(array $form, FormStateInterface $form_state) {
// Rebuild the form.
$form_state->setRebuild();
$this->entity = $preview->getFormObject()->getEntity();
unset($this->entity->in_preview);
$this->entity->in_preview = NULL;
// Remove the stale temp store entry for existing nodes.
if (!$this->entity->isNew()) {
......
......@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Language\LanguageInterface;
......@@ -21,13 +22,14 @@
class PagePreviewTest extends NodeTestBase {
use EntityReferenceTestTrait;
use CommentTestTrait;
/**
* Enable the node and taxonomy modules to test both on the preview.
* Enable the comment, node and taxonomy modules to test on the preview.
*
* @var array
*/
public static $modules = array('node', 'taxonomy');
public static $modules = array('node', 'taxonomy', 'comment');
/**
* The name of the created field.
......@@ -38,6 +40,7 @@ class PagePreviewTest extends NodeTestBase {
protected function setUp() {
parent::setUp();
$this->addDefaultCommentField('node', 'page');
$web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
$this->drupalLogin($web_user);
......@@ -139,6 +142,14 @@ function testPagePreview() {
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertFieldByName($term_key, $edit[$term_key] . ' (' . $this->term->id() . ')', 'Term field displayed.');
// Return to page preview to check everything is as expected.
$this->drupalPostForm(NULL, array(), t('Preview'));
$this->assertTitle(t('@title | Drupal', array('@title' => $edit[$title_key])), 'Basic page title is preview.');
$this->assertText($edit[$title_key], 'Title displayed.');
$this->assertText($edit[$body_key], 'Body displayed.');
$this->assertText($edit[$term_key], 'Term displayed.');
$this->assertLink(t('Back to content editing'));
// Assert the content is kept when reloading the page.
$this->drupalGet('node/add/page', array('query' => array('uuid' => $uuid)));
$this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment