1 node_views_revision_relations.test public NodeViewsRevisionRelationsTestCase::testNodeRevisionRelationship()

Create a node with revision and rest result count for both views.

File

core/modules/node/tests/node_views_revision_relations.test, line 26
Definition of ViewsNodeRevisionRelationsTestCase.

Class

NodeViewsRevisionRelationsTestCase
Tests basic node_revision table integration into views.

Code

public function testNodeRevisionRelationship() {
  $node = $this->backdropCreateNode();
  // Create revision of the node.
  $node_revision = clone $node;
  $node_revision->revision = 1;
  $node_revision->save();
  $column_map = array(
    'vid' => 'vid',
    'node_revision_nid' => 'node_revision_nid',
    'node_node_revision_nid' => 'node_node_revision_nid',
  );

  // Here should be two rows.
  $view_nid = $this->test_view_node_revision_nid();
  $this->executeView($view_nid, array($node->nid));
  $resultset_nid = array(
    array(
      'vid' => '1',
      'node_revision_nid' => $node->nid,
      'node_node_revision_nid' => $node->nid,
    ),
    array(
      'vid' => '2',
      'node_revision_nid' => $node->nid,
      'node_node_revision_nid' => $node->nid,
    ),
  );
  $this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);

  // There should be only one row with active revision 2.
  $view_vid = $this->test_view_node_revision_vid();
  $this->executeView($view_vid, array($node->nid));
  $resultset_vid = array(
    array(
      'vid' => '2',
      'node_revision_nid' => '1',
      'node_node_revision_nid' => '1',
    ),
  );
  $this->assertIdenticalResultset($view_vid, $resultset_vid, $column_map);
}