NextIdTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Database;
class NextIdTest extends DatabaseTestBase {
public static $modules = [
'database_test',
'system',
];
protected function setUp() {
parent::setUp();
$this
->installSchema('system', 'sequences');
}
public function testDbNextId() {
$first = $this->connection
->nextId();
$second = $this->connection
->nextId();
$this
->assertEqual($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
$result = $this->connection
->nextId(1000);
$this
->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');
}
}