HistoryLegacyTest.php in Drupal 8
File
core/modules/history/tests/src/Kernel/HistoryLegacyTest.php
View source
<?php
namespace Drupal\Tests\history\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\user\Entity\User;
class HistoryLegacyTest extends KernelTestBase {
protected static $modules = [
'history',
'node',
'user',
'system',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('node');
$this
->installEntitySchema('user');
$this
->installSchema('history', [
'history',
]);
$this
->installSchema('system', [
'sequences',
]);
}
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]);
}
}