You are here

function NextIdTest::testDbNextId in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/NextIdTest.php \Drupal\system\Tests\Database\NextIdTest::testDbNextId()

Tests that the sequences API works.

File

core/modules/system/src/Tests/Database/NextIdTest.php, line 33
Contains \Drupal\system\Tests\Database\NextIdTest.

Class

NextIdTest
Tests the sequences API.

Namespace

Drupal\system\Tests\Database

Code

function testDbNextId() {
  $first = db_next_id();
  $second = db_next_id();

  // We can test for exact increase in here because we know there is no
  // other process operating on these tables -- normally we could only
  // expect $second > $first.
  $this
    ->assertEqual($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
  $result = db_next_id(1000);
  $this
    ->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');
}