3 namespace Drupal\KernelTests\Core\Database;
5 use Drupal\KernelTests\KernelTestBase;
8 * Tests the sequences API.
12 class NextIdTest extends KernelTestBase {
15 * The modules to enable.
18 public static $modules = ['system'];
20 protected function setUp() {
22 $this->installSchema('system', 'sequences');
26 * Tests that the sequences API works.
28 public function testDbNextId() {
29 $first = db_next_id();
30 $second = db_next_id();
31 // We can test for exact increase in here because we know there is no
32 // other process operating on these tables -- normally we could only
33 // expect $second > $first.
34 $this->assertEqual($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
35 $result = db_next_id(1000);
36 $this->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');