function KernelTestBase::resetEnvironment
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::resetEnvironment()
Resets the environment after a test method has run.
See also
\Drupal\TestTools\Attribute\ShareEnvironment
5 calls to KernelTestBase::resetEnvironment()
- FieldConfigValidationTest::resetEnvironment in core/
modules/ field/ tests/ src/ Kernel/ Entity/ FieldConfigValidationTest.php - Resets the environment after a test method has run.
- KernelTestBase::tearDownEnvironment in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Cleans the environment up after a test method and checks the result.
- NodeTypeValidationTest::resetEnvironment in core/
modules/ node/ tests/ src/ Kernel/ NodeTypeValidationTest.php - Resets the environment after a test method has run.
- SharedDatabaseStateTest::resetEnvironment in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateTest.php - Resets the environment after a test method has run.
- SharedDatabaseStateViolationTest::resetEnvironment in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateViolationTest.php - Resets the environment after a test method has run.
4 methods override KernelTestBase::resetEnvironment()
- FieldConfigValidationTest::resetEnvironment in core/
modules/ field/ tests/ src/ Kernel/ Entity/ FieldConfigValidationTest.php - Resets the environment after a test method has run.
- NodeTypeValidationTest::resetEnvironment in core/
modules/ node/ tests/ src/ Kernel/ NodeTypeValidationTest.php - Resets the environment after a test method has run.
- SharedDatabaseStateTest::resetEnvironment in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateTest.php - Resets the environment after a test method has run.
- SharedDatabaseStateViolationTest::resetEnvironment in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateViolationTest.php - Resets the environment after a test method has run.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 898
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
protected function resetEnvironment() : void {
if (static::sharesEnvironment()) {
return;
}
// Remove all prefixed tables.
$original_connection_info = Database::getConnectionInfo('simpletest_original_default');
$original_prefix = $original_connection_info['default']['prefix'] ?? NULL;
$test_connection_info = Database::getConnectionInfo('default');
$test_prefix = $test_connection_info['default']['prefix'] ?? NULL;
if ($original_prefix != $test_prefix) {
$tables = Database::getConnection()->schema()
->findTables('%');
foreach ($tables as $table) {
if (Database::getConnection()->schema()
->dropTable($table)) {
unset($tables[$table]);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.