You are here

public function ArgumentNodeRevisionIdTest::testNodeRevisionRelationship in Drupal 10

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()

Tests the node revision id argument via the node_vid handler.

File

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

Class

ArgumentNodeRevisionIdTest
Tests the node_vid handler.

Namespace

Drupal\Tests\node\Kernel\Views

Code

public function testNodeRevisionRelationship() {
  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());
}