function ArgumentNodeRevisionIdTest::testNodeRevisionRelationship

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Kernel/Views/ArgumentNodeRevisionIdTest.php \Drupal\Tests\node\Kernel\Views\ArgumentNodeRevisionIdTest::testNodeRevisionRelationship()
  2. 11.x core/modules/node/tests/src/Kernel/Views/ArgumentNodeRevisionIdTest.php \Drupal\Tests\node\Kernel\Views\ArgumentNodeRevisionIdTest::testNodeRevisionRelationship()

Tests the node revision id argument via the node_vid handler.

File

core/modules/node/tests/src/Kernel/Views/ArgumentNodeRevisionIdTest.php, line 46

Class

ArgumentNodeRevisionIdTest
Tests the node_vid handler.

Namespace

Drupal\Tests\node\Kernel\Views

Code

public function testNodeRevisionRelationship() : void {
  NodeType::create([
    'type' => 'page',
    'name' => 'page',
  ])->save();
  $node = Node::create([
    'type' => 'page',
    'title' => 'test1',
    'uid' => 1,
  ]);
  $node->save();
  $first_revision_id = $node->getRevisionId();
  $node->setNewRevision();
  $node->setTitle('test2');
  $node->save();
  $second_revision_id = $node->getRevisionId();
  $view_nid = Views::getView('test_node_revision_id_argument');
  $this->executeView($view_nid, [
    $second_revision_id,
  ]);
  $this->assertIdenticalResultset($view_nid, [
    [
      'title' => 'test2',
    ],
  ]);
  $this->assertSame('test2', $view_nid->getTitle());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.