Commit c5bfca64 authored by alexpott's avatar alexpott

Issue #2684213 by amateescu, larowlan, josephdpurcell, dawehner: Preview on...

Issue #2684213 by amateescu, larowlan, josephdpurcell, dawehner: Preview on forward node revisions throws an error
parent cf6909c8
......@@ -22,26 +22,6 @@ public function view(EntityInterface $node_preview, $view_mode_id = 'full', $lan
// Don't render cache previews.
unset($build['#cache']);
foreach ($node_preview->uriRelationships() as $rel) {
// Set the node path as the canonical URL to prevent duplicate content.
$build['#attached']['html_head_link'][] = array(
array(
'rel' => $rel,
'href' => $node_preview->url($rel),
)
, TRUE);
if ($rel == 'canonical') {
// Set the non-aliased canonical path as a default shortlink.
$build['#attached']['html_head_link'][] = array(
array(
'rel' => 'shortlink',
'href' => $node_preview->url($rel, array('alias' => TRUE)),
)
, TRUE);
}
}
return $build;
}
......
......@@ -296,6 +296,24 @@ function testPagePreviewWithRevisions() {
// Check that the revision log field has the correct value.
$this->assertFieldByName('revision_log[0][value]', $edit['revision_log[0][value]'], 'Revision log field displayed.');
// Save the node after coming back from the preview page so we can create a
// forward revision for it.
$this->drupalPostForm(NULL, [], t('Save'));
$node = $this->drupalGetNodeByTitle($edit[$title_key]);
// Check that previewing a forward revision of a node works. This can not be
// accomplished through the UI so we have to use API calls.
// @todo Change this test to use the UI when we will be able to create
// forward revisions in core.
// @see https://www.drupal.org/node/2725533
$node->setNewRevision(TRUE);
$node->isDefaultRevision(FALSE);
/** @var \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver */
$controller_resolver = \Drupal::service('controller_resolver');
$node_preview_controller = $controller_resolver->getControllerFromDefinition('\Drupal\node\Controller\NodePreviewController::view');
$node_preview_controller($node, 'default');
}
/**
......
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