72 lines
2.0 KiB
Plaintext
72 lines
2.0 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Uninstall functions for the simpletest module.
|
|
*/
|
|
|
|
use Drupal\Core\Database\Database;
|
|
use Drupal\Core\File\Exception\FileException;
|
|
use Drupal\Core\Test\EnvironmentCleaner;
|
|
use Drupal\Core\Test\TestDatabase;
|
|
use Symfony\Component\Console\Output\NullOutput;
|
|
|
|
/**
|
|
* Implements hook_requirements().
|
|
*/
|
|
function simpletest_requirements($phase) {
|
|
$requirements = [];
|
|
// Notify about the module being deprecated.
|
|
if ($phase == 'install' || $phase == 'runtime') {
|
|
$requirements['simpletest'] = [
|
|
'title' => t('SimpleTest'),
|
|
'severity' => REQUIREMENT_ERROR,
|
|
'description' => t('SimpleTest has been removed from Drupal 9.0.0 and can no longer be installed. A contributed module is available for those who wish to continue using SimpleTest during the transition from Drupal 8 to 9. <a href=":change-record">See the change record for more information</a>.', [
|
|
':change-record' => 'https://www.drupal.org/node/3091784',
|
|
]),
|
|
];
|
|
}
|
|
|
|
return $requirements;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_schema().
|
|
*/
|
|
function simpletest_schema() {
|
|
return TestDatabase::testingSchema();
|
|
}
|
|
|
|
/**
|
|
* Implements hook_uninstall().
|
|
*/
|
|
function simpletest_uninstall() {
|
|
// Do not clean the environment in case the Simpletest module is uninstalled
|
|
// in a (recursive) test for itself, since EnvironmentCleaner would also
|
|
// delete the test site of the parent test process.
|
|
if (!drupal_valid_test_ua()) {
|
|
// Clean up left-over tables and directories.
|
|
$cleaner = new EnvironmentCleaner(
|
|
DRUPAL_ROOT,
|
|
Database::getConnection(),
|
|
TestDatabase::getConnection(),
|
|
new NullOutput(),
|
|
\Drupal::service('file_system')
|
|
);
|
|
try {
|
|
$cleaner->cleanEnvironment();
|
|
}
|
|
catch (Exception $e) {
|
|
// Ignore.
|
|
}
|
|
}
|
|
|
|
// Delete verbose test output and any other testing framework files.
|
|
try {
|
|
\Drupal::service('file_system')->deleteRecursive('public://simpletest');
|
|
}
|
|
catch (FileException $e) {
|
|
// Ignore.
|
|
}
|
|
}
|