class DatabaseVersionCheckUpdateTest
Same name and namespace in other branches
- 10 core/modules/system/tests/src/Functional/Update/DatabaseVersionCheckUpdateTest.php \Drupal\Tests\system\Functional\Update\DatabaseVersionCheckUpdateTest
- 8.9.x core/modules/system/tests/src/Functional/Update/DatabaseVersionCheckUpdateTest.php \Drupal\Tests\system\Functional\Update\DatabaseVersionCheckUpdateTest
Tests that updates fail if the database does not meet the minimum version.
@group Update
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Update\DatabaseVersionCheckUpdateTest uses \Drupal\Tests\UpdatePathTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of DatabaseVersionCheckUpdateTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Update/ DatabaseVersionCheckUpdateTest.php, line 15
Namespace
Drupal\Tests\system\Functional\UpdateView source
class DatabaseVersionCheckUpdateTest extends BrowserTestBase {
use UpdatePathTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->ensureUpdatesToRun();
}
/**
* Tests that updates fail if the database does not meet the minimum version.
*/
public function testUpdate() {
if (Database::getConnection()->driver() !== 'mysql') {
$this->markTestSkipped('This test only works with the mysql driver');
}
// Use a database driver that reports a fake database version that does
// not meet requirements. Only change the necessary settings in the database
// settings array so that run-tests.sh continues to work.
$autoload = Database::findDriverAutoloadDirectory('Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion', \Drupal::root());
$settings['databases']['default']['default']['driver'] = (object) [
'value' => 'DrivertestMysqlDeprecatedVersion',
'required' => TRUE,
];
$settings['databases']['default']['default']['namespace'] = (object) [
'value' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysqlDeprecatedVersion',
'required' => TRUE,
];
$settings['databases']['default']['default']['autoload'] = (object) [
'value' => $autoload,
'required' => TRUE,
];
$settings['settings'] = [
'update_free_access' => (object) [
'value' => TRUE,
'required' => TRUE,
],
];
$this->writeSettings($settings);
$this->drupalGet(Url::fromRoute('system.db_update'));
$this->assertSession()
->pageTextContains('Errors found');
$this->assertSession()
->pageTextContains('The database server version 10.2.31-MariaDB-1:10.2.31+maria~bionic-log is less than the minimum required version');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.