function DatabaseNextIdCase::testDbNextId
Test that the sequences API work.
File
-
modules/
simpletest/ tests/ database_test.test, line 4218
Class
- DatabaseNextIdCase
- Check the sequences API.
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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.