function RevisionCreateTimestampTest::testRevisionCreateTimestampView

Same name in other branches
  1. 9 core/modules/node/tests/src/Kernel/Views/RevisionCreateTimestampTest.php \Drupal\Tests\node\Kernel\Views\RevisionCreateTimestampTest::testRevisionCreateTimestampView()
  2. 8.9.x core/modules/node/tests/src/Kernel/Views/RevisionCreateTimestampTest.php \Drupal\Tests\node\Kernel\Views\RevisionCreateTimestampTest::testRevisionCreateTimestampView()
  3. 10 core/modules/node/tests/src/Kernel/Views/RevisionCreateTimestampTest.php \Drupal\Tests\node\Kernel\Views\RevisionCreateTimestampTest::testRevisionCreateTimestampView()

File

core/modules/node/tests/src/Kernel/Views/RevisionCreateTimestampTest.php, line 45

Class

RevisionCreateTimestampTest
Ensures that the revision create time can be accessed in views.

Namespace

Drupal\Tests\node\Kernel\Views

Code

public function testRevisionCreateTimestampView() : void {
    $node_type = NodeType::create([
        'type' => 'article',
        'name' => 'Article',
    ]);
    $node_type->save();
    $node = Node::create([
        'title' => 'Test node',
        'type' => 'article',
        'revision_timestamp' => 1000,
    ]);
    $node->save();
    $node->setRevisionCreationTime(1200);
    $node->setNewRevision(TRUE);
    $node->save();
    $node->setRevisionCreationTime(1400);
    $node->setNewRevision(TRUE);
    $node->save();
    $view = Views::getView('test_node_revision_timestamp');
    $this->executeView($view);
    $this->assertIdenticalResultset($view, [
        [
            'vid' => 3,
            'revision_timestamp' => 1400,
        ],
        [
            'vid' => 2,
            'revision_timestamp' => 1200,
        ],
        [
            'vid' => 1,
            'revision_timestamp' => 1000,
        ],
    ], [
        'vid' => 'vid',
        'revision_timestamp' => 'revision_timestamp',
    ]);
}

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