function HistoryLegacyTest::testHistoryAttachTimestamp

Tests history_attach_timestamp() deprecation.

@expectedDeprecation history_attach_timestamp() is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Use \Drupal\history\HistoryRenderCallback::lazyBuilder() instead. See https://www.drupal.org/node/2966725

File

core/modules/history/tests/src/Kernel/HistoryLegacyTest.php, line 40

Class

HistoryLegacyTest
Tests History module's legacy code.

Namespace

Drupal\Tests\history\Kernel

Code

public function testHistoryAttachTimestamp() {
    $node = Node::create([
        'title' => 'n1',
        'type' => 'default',
    ]);
    $node->save();
    $user1 = User::create([
        'name' => 'user1',
        'mail' => 'user1@example.com',
    ]);
    $user1->save();
    \Drupal::currentUser()->setAccount($user1);
    history_write(1);
    $render = history_attach_timestamp(1);
    $this->assertEquals(REQUEST_TIME, $render['#attached']['drupalSettings']['history']['lastReadTimestamps'][1]);
}

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