class NextIdTest
Same name in this branch
- 9 core/modules/mysql/tests/src/Kernel/mysql/NextIdTest.php \Drupal\Tests\mysql\Kernel\mysql\NextIdTest
Tests the sequences API.
@group Database
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase uses \Drupal\KernelTests\Core\Database\DatabaseTestSchemaDataTrait, \Drupal\KernelTests\Core\Database\DatabaseTestSchemaInstallTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Database\NextIdTest implements \Drupal\KernelTests\Core\Database\DatabaseTestBase
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase uses \Drupal\KernelTests\Core\Database\DatabaseTestSchemaDataTrait, \Drupal\KernelTests\Core\Database\DatabaseTestSchemaInstallTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of NextIdTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ NextIdTest.php, line 10
Namespace
Drupal\KernelTests\Core\DatabaseView source
class NextIdTest extends DatabaseTestBase {
/**
* The modules to enable.
*
* @var array
*/
protected static $modules = [
'database_test',
'system',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installSchema('system', 'sequences');
}
/**
* Tests that the sequences API works.
*/
public function testDbNextId() {
$first = $this->connection
->nextId();
$second = $this->connection
->nextId();
// 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->assertEquals($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
$result = $this->connection
->nextId(1000);
$this->assertEquals(1001, $result, '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.