function UpdatePathTest::testLogEntryWithBigId
Same name in other branches
- 10 core/modules/dblog/tests/src/Functional/UpdatePathTest.php \Drupal\Tests\dblog\Functional\UpdatePathTest::testLogEntryWithBigId()
Tests that, after update 10101, the 'wid' column can be a 64-bit integer.
File
-
core/
modules/ dblog/ tests/ src/ Functional/ UpdatePathTest.php, line 42
Class
- UpdatePathTest
- Tests update functions for the Database Logging module.
Namespace
Drupal\Tests\dblog\FunctionalCode
public function testLogEntryWithBigId() {
if (PHP_INT_SIZE < 8) {
$this->markTestSkipped('This test can only be run on a system that supports 64-bit integers (i.e., PHP_INT_SIZE is 8).');
}
$this->runUpdates();
global $base_root;
$connection = Database::getConnection();
// Insert a row with a big value for wid.
$insert = $connection->insert('watchdog');
$insert->fields([
'wid' => 2147483647000,
'message' => 'Dblog test log message with big WID',
'type' => 'test',
'variables' => '',
'severity' => RfcLogLevel::NOTICE,
'uid' => 1,
'location' => $base_root . \Drupal::request()->getRequestUri(),
'hostname' => $base_root,
'timestamp' => \Drupal::time()->getRequestTime(),
]);
$insert->execute();
// Insert another row without a value for wid, to test auto-increment.
$insert = $connection->insert('watchdog');
$insert->fields([
'message' => 'Dblog test log message with big WID',
'type' => 'test',
'variables' => '',
'severity' => RfcLogLevel::NOTICE,
'uid' => 1,
'location' => $base_root . \Drupal::request()->getRequestUri(),
'hostname' => $base_root,
'timestamp' => \Drupal::time()->getRequestTime(),
]);
$insert->execute();
// Test that the first row exists with the expected value for wid.
$result = $connection->select('watchdog')
->fields('watchdog', [
'wid',
])
->condition('wid', 2147483647000)
->execute()
->fetchAssoc();
$this->assertNotEmpty($result, 'The row with a big value for wid exists.');
// Test that the second row exists with the expected value for wid.
$result = $connection->select('watchdog')
->fields('watchdog', [
'wid',
])
->condition('wid', 2147483647000 + 1)
->execute()
->fetchAssoc();
$this->assertNotEmpty($result, 'The row without a value for wid exists, and has the correct auto-incremented value for wid.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.