class NextIdTest
Same name in this branch
- 9 core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php \Drupal\KernelTests\Core\Database\NextIdTest
Same name and namespace in other branches
- 10 core/modules/mysql/tests/src/Kernel/mysql/NextIdTest.php \Drupal\Tests\mysql\Kernel\mysql\NextIdTest
- 10 core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php \Drupal\KernelTests\Core\Database\NextIdTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php \Drupal\KernelTests\Core\Database\NextIdTest
Tests the sequences API.
@group Database
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \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 extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase uses \Drupal\KernelTests\Core\Database\DatabaseTestSchemaDataTrait, \Drupal\KernelTests\Core\Database\DatabaseTestSchemaInstallTrait extends \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
- class \Drupal\Tests\mysql\Kernel\mysql\NextIdTest extends \Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase
- class \Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase uses \Drupal\KernelTests\Core\Database\DatabaseTestSchemaDataTrait, \Drupal\KernelTests\Core\Database\DatabaseTestSchemaInstallTrait extends \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of NextIdTest
File
-
core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ NextIdTest.php, line 13
Namespace
Drupal\Tests\mysql\Kernel\mysqlView source
class NextIdTest extends DriverSpecificDatabaseTestBase {
/**
* 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 sequences table clear up works when a connection is closed.
*
* @see \Drupal\mysql\Driver\Database\mysql\Connection::__destruct()
*/
public function testDbNextIdClosedConnection() {
// Create an additional connection to test closing the connection.
$connection_info = Database::getConnectionInfo();
Database::addConnectionInfo('default', 'next_id', $connection_info['default']);
// Get a few IDs to ensure there the clean up needs to run and there is more
// than one row.
Database::getConnection('next_id')->nextId();
Database::getConnection('next_id')->nextId();
// At this point the sequences table should contain unnecessary rows.
$count = $this->connection
->select('sequences')
->countQuery()
->execute()
->fetchField();
$this->assertGreaterThan(1, $count);
// Close the connection.
Database::closeConnection('next_id');
// Test that \Drupal\mysql\Driver\Database\mysql\Connection::__destruct()
// successfully trims the sequences table if the connection is closed.
$count = $this->connection
->select('sequences')
->countQuery()
->execute()
->fetchField();
$this->assertEquals(1, $count);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.