Commit c47466e9 authored by catch's avatar catch

Issue #2229167 by dawehner, marthinal, Bojhan: Broken/missing handler (Module: node)

parent 341b903d
......@@ -27,7 +27,7 @@ class NodeRevision extends WizardPluginBase {
/**
* Set the created column.
*/
protected $createdColumn = 'timestamp';
protected $createdColumn = 'changed';
/**
* Set default values for the path field options.
......@@ -95,20 +95,20 @@ protected function defaultDisplayOptions() {
unset($display_options['fields']);
/* Field: Content revision: Created date */
$display_options['fields']['timestamp']['id'] = 'timestamp';
$display_options['fields']['timestamp']['table'] = 'node_revision';
$display_options['fields']['timestamp']['field'] = 'timestamp';
$display_options['fields']['timestamp']['provider'] = 'node';
$display_options['fields']['timestamp']['alter']['alter_text'] = 0;
$display_options['fields']['timestamp']['alter']['make_link'] = 0;
$display_options['fields']['timestamp']['alter']['absolute'] = 0;
$display_options['fields']['timestamp']['alter']['trim'] = 0;
$display_options['fields']['timestamp']['alter']['word_boundary'] = 0;
$display_options['fields']['timestamp']['alter']['ellipsis'] = 0;
$display_options['fields']['timestamp']['alter']['strip_tags'] = 0;
$display_options['fields']['timestamp']['alter']['html'] = 0;
$display_options['fields']['timestamp']['hide_empty'] = 0;
$display_options['fields']['timestamp']['empty_zero'] = 0;
$display_options['fields']['changed']['id'] = 'changed';
$display_options['fields']['changed']['table'] = 'node_field_revision';
$display_options['fields']['changed']['field'] = 'changed';
$display_options['fields']['changed']['provider'] = 'node';
$display_options['fields']['changed']['alter']['alter_text'] = FALSE;
$display_options['fields']['changed']['alter']['make_link'] = FALSE;
$display_options['fields']['changed']['alter']['absolute'] = FALSE;
$display_options['fields']['changed']['alter']['trim'] = FALSE;
$display_options['fields']['changed']['alter']['word_boundary'] = FALSE;
$display_options['fields']['changed']['alter']['ellipsis'] = FALSE;
$display_options['fields']['changed']['alter']['strip_tags'] = FALSE;
$display_options['fields']['changed']['alter']['html'] = FALSE;
$display_options['fields']['changed']['hide_empty'] = FALSE;
$display_options['fields']['changed']['empty_zero'] = FALSE;
/* Field: Content revision: Title */
$display_options['fields']['title']['id'] = 'title';
......
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\NodeRevisionWizardTest.
*/
namespace Drupal\node\Tests\Views;
use Drupal\views\Tests\Wizard\WizardTestBase;
use Drupal\views\Views;
/**
* Tests the wizard with node_revision as base table.
*
* @see \Drupal\node\Plugin\views\wizard\NodeRevision
*/
class NodeRevisionWizardTest extends WizardTestBase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Node revision wizard',
'description' => 'Tests the wizard with node_revision as base table.',
'group' => 'Views Wizard',
);
}
/**
* Tests creating a node revision view.
*/
public function testViewAdd() {
$this->drupalCreateContentType(array('type' => 'article'));
// Create two nodes with two revision.
$node_storage = \Drupal::entityManager()->getStorage('node');
/** @var \Drupal\node\NodeInterface $node */
$node = $node_storage->create(array('type' => 'article', 'created' => REQUEST_TIME + 40));
$node->save();
$node = $node->createDuplicate();
$node->setNewRevision();
$node->created->value = REQUEST_TIME + 20;
$node->save();
$node = $node_storage->create(array('type' => 'article', 'created' => REQUEST_TIME + 30));
$node->save();
$node = $node->createDuplicate();
$node->setNewRevision();
$node->created->value = REQUEST_TIME + 10;
$node->save();
$view = array();
$view['label'] = $this->randomName(16);
$view['id'] = strtolower($this->randomName(16));
$view['description'] = $this->randomName(16);
$view['page[create]'] = FALSE;
$view['show[wizard_key]'] = 'node_revision';
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$view_storage_controller = \Drupal::entityManager()->getStorage('view');
/** @var \Drupal\views\Entity\View $view */
$view = $view_storage_controller->load($view['id']);
$this->assertEqual($view->get('base_table'), 'node_revision');
$executable = Views::executableFactory()->get($view);
$this->executeView($executable);
$this->assertIdenticalResultset($executable, array(array('vid' => 1), array('vid' => 3), array('vid' => 2), array('vid' => 4)),
array('node_field_revision_vid' => 'vid'));
}
}
......@@ -517,6 +517,10 @@ function node_views_data() {
'left_field' => 'vid',
'field' => 'vid',
),
'node_revision' => array(
'left_field' => 'vid',
'field' => 'vid',
),
);
$data['node_field_revision']['status'] = array(
......
......@@ -93,7 +93,7 @@ protected function enableViewsTestModule() {
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
protected function assertIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set.') {
protected function assertIdenticalResultset(ViewExecutable $view, $expected_result, $column_map = array(), $message = 'Identical result set.') {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertIdentical');
}
......@@ -116,7 +116,7 @@ protected function assertIdenticalResultset($view, $expected_result, $column_map
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
*/
protected function assertNotIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Non-identical result set.') {
protected function assertNotIdenticalResultset(ViewExecutable $view, $expected_result, $column_map = array(), $message = 'Non-identical result set.') {
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertNotIdentical');
}
......@@ -145,7 +145,7 @@ protected function assertNotIdenticalResultset($view, $expected_result, $column_
* @see \Drupal\views\Tests\ViewTestBase::assertIdenticalResultset()
* @see \Drupal\views\Tests\ViewTestBase::assertNotIdenticalResultset()
*/
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, $assert_method) {
protected function assertIdenticalResultsetHelper(ViewExecutable $view, $expected_result, $column_map, $message, $assert_method) {
// Convert $view->result to an array of arrays.
$result = array();
foreach ($view->result as $key => $value) {
......@@ -229,7 +229,7 @@ protected function helperButtonHasLabel($id, $expected_label, $message = 'Label
* @param array $args
* (optional) An array of the view arguments to use for the view.
*/
protected function executeView($view, $args = array()) {
protected function executeView(ViewExecutable $view, $args = array()) {
// A view does not really work outside of a request scope, due to many
// dependencies like the current user.
$this->container->enterScope('request');
......
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