Loading core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\FunctionalTests\Installer\InstallerTestBase; use Drupal\Core\Config\InstallStorage; use Drupal\Core\Serialization\Yaml; use Drupal\Tests\RequirementsPageTrait; /** * Tests install profile config overrides can not add unmet dependencies. Loading @@ -13,6 +14,8 @@ */ class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase { use RequirementsPageTrait; /** * The installation profile to install. * Loading core/modules/system/system.install +6 −16 Original line number Diff line number Diff line Loading @@ -292,27 +292,17 @@ function system_requirements($phase) { ':php_requirements' => 'https://www.drupal.org/docs/9/how-drupal-9-is-made-and-what-is-included/environment-requirements-of-drupal-9#s-php-version-requirement', ] ); $requirements['php']['severity'] = REQUIREMENT_ERROR; // If the PHP version is also below the absolute minimum allowed, it's not // safe to continue with the requirements check. // safe to continue with the requirements check, and should always be an // error. if (version_compare($phpversion, \Drupal::MINIMUM_PHP) < 0) { $requirements['php']['severity'] = REQUIREMENT_ERROR; return $requirements; } // Otherwise downgrade the error to a warning during updates. Even if there // are some problems with the site's PHP version, it's still better for the // site to keep its Drupal codebase up to date. elseif ($phase === 'update') { $requirements['php']['severity'] = REQUIREMENT_WARNING; } // Since we allow sites with unsupported PHP versions to still run Drupal // updates, we also need to be able to run tests with those PHP versions, // which requires the ability to install test sites. Not all tests are // required to pass on these PHP versions, but we want to monitor which // ones do and don't. elseif ($phase === 'install' && drupal_valid_test_ua()) { $requirements['php']['severity'] = REQUIREMENT_INFO; } // Otherwise, the message should be an error at runtime, and a warning // during installation or update. $requirements['php']['severity'] = ($phase === 'runtime') ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; } // For PHP versions that are still supported but no longer recommended, // inform users of what's recommended, allowing them to take action before it Loading core/modules/system/tests/src/Functional/System/PhpRequirementTest.php 0 → 100644 +81 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\system\Functional\System; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\RequirementsPageTrait; /** * Tests the output of PHP requirements on the status report. * * @group system */ class PhpRequirementTest extends BrowserTestBase { use RequirementsPageTrait; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $admin_user = $this->drupalCreateUser([ 'administer site configuration', 'access site reports', ]); $this->drupalLogin($admin_user); // By default, Drupal installation (and BrowserTestBase) do not configure // trusted host patterns, which leads to an error on the status report. // Configure them so that the site is properly configured and so that we // can cleanly test the errors related to PHP versions. $settings['settings']['trusted_host_patterns'] = (object) [ 'value' => ['^' . preg_quote(\Drupal::request()->getHost()) . '$'], 'required' => TRUE, ]; $this->writeSettings($settings); } /** * Tests status report messages regarding the PHP version. */ public function testStatusPage() { // Go to Administration. $this->drupalGet('admin/reports/status'); $this->assertSession()->statusCodeEquals(200); $phpversion = phpversion(); // Verify that the PHP version is shown on the page. $this->assertSession()->pageTextContains($phpversion); // Verify that an error is displayed about the PHP version if it is below // the minimum supported PHP. if (version_compare($phpversion, \Drupal::MINIMUM_SUPPORTED_PHP) < 0) { $this->assertErrorSummaries(['PHP']); $this->assertSession()->pageTextContains('Your PHP installation is too old. Drupal requires at least PHP ' . \Drupal::MINIMUM_SUPPORTED_PHP); } // Otherwise, there should be no error. else { $this->assertSession()->pageTextNotContains('Your PHP installation is too old. Drupal requires at least PHP ' . \Drupal::MINIMUM_SUPPORTED_PHP); $this->assertSession()->pageTextNotContains('Errors found'); } // There should be an informational message if the PHP version is below the // recommended version. if (version_compare($phpversion, \Drupal::RECOMMENDED_PHP) < 0) { $this->assertSession()->pageTextContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher'); } // Otherwise, the message should not be there. else { $this->assertSession()->pageTextNotContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher'); } } } core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,15 @@ protected function setUpSettings() { // screen. } /** * {@inheritdoc} */ protected function setUpRequirementsProblem() { // The parent method asserts that there are no requirements errors, but // this test expects a requirements error in the test method below. // Therefore, we override this method to suppress the parent's assertions. } /** * {@inheritdoc} */ Loading core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,15 @@ protected function setUpSettings() { // This form will never be reached. } /** * {@inheritdoc} */ protected function setUpRequirementsProblem() { // The parent method asserts that there are no requirements errors, but // this test expects a requirements error in the test method below. // Therefore, we override this method to suppress the parent's assertions. } /** * {@inheritdoc} */ Loading Loading
core/modules/config/tests/src/Functional/ConfigInstallProfileUnmetDependenciesTest.php +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\FunctionalTests\Installer\InstallerTestBase; use Drupal\Core\Config\InstallStorage; use Drupal\Core\Serialization\Yaml; use Drupal\Tests\RequirementsPageTrait; /** * Tests install profile config overrides can not add unmet dependencies. Loading @@ -13,6 +14,8 @@ */ class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase { use RequirementsPageTrait; /** * The installation profile to install. * Loading
core/modules/system/system.install +6 −16 Original line number Diff line number Diff line Loading @@ -292,27 +292,17 @@ function system_requirements($phase) { ':php_requirements' => 'https://www.drupal.org/docs/9/how-drupal-9-is-made-and-what-is-included/environment-requirements-of-drupal-9#s-php-version-requirement', ] ); $requirements['php']['severity'] = REQUIREMENT_ERROR; // If the PHP version is also below the absolute minimum allowed, it's not // safe to continue with the requirements check. // safe to continue with the requirements check, and should always be an // error. if (version_compare($phpversion, \Drupal::MINIMUM_PHP) < 0) { $requirements['php']['severity'] = REQUIREMENT_ERROR; return $requirements; } // Otherwise downgrade the error to a warning during updates. Even if there // are some problems with the site's PHP version, it's still better for the // site to keep its Drupal codebase up to date. elseif ($phase === 'update') { $requirements['php']['severity'] = REQUIREMENT_WARNING; } // Since we allow sites with unsupported PHP versions to still run Drupal // updates, we also need to be able to run tests with those PHP versions, // which requires the ability to install test sites. Not all tests are // required to pass on these PHP versions, but we want to monitor which // ones do and don't. elseif ($phase === 'install' && drupal_valid_test_ua()) { $requirements['php']['severity'] = REQUIREMENT_INFO; } // Otherwise, the message should be an error at runtime, and a warning // during installation or update. $requirements['php']['severity'] = ($phase === 'runtime') ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; } // For PHP versions that are still supported but no longer recommended, // inform users of what's recommended, allowing them to take action before it Loading
core/modules/system/tests/src/Functional/System/PhpRequirementTest.php 0 → 100644 +81 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\system\Functional\System; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\RequirementsPageTrait; /** * Tests the output of PHP requirements on the status report. * * @group system */ class PhpRequirementTest extends BrowserTestBase { use RequirementsPageTrait; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $admin_user = $this->drupalCreateUser([ 'administer site configuration', 'access site reports', ]); $this->drupalLogin($admin_user); // By default, Drupal installation (and BrowserTestBase) do not configure // trusted host patterns, which leads to an error on the status report. // Configure them so that the site is properly configured and so that we // can cleanly test the errors related to PHP versions. $settings['settings']['trusted_host_patterns'] = (object) [ 'value' => ['^' . preg_quote(\Drupal::request()->getHost()) . '$'], 'required' => TRUE, ]; $this->writeSettings($settings); } /** * Tests status report messages regarding the PHP version. */ public function testStatusPage() { // Go to Administration. $this->drupalGet('admin/reports/status'); $this->assertSession()->statusCodeEquals(200); $phpversion = phpversion(); // Verify that the PHP version is shown on the page. $this->assertSession()->pageTextContains($phpversion); // Verify that an error is displayed about the PHP version if it is below // the minimum supported PHP. if (version_compare($phpversion, \Drupal::MINIMUM_SUPPORTED_PHP) < 0) { $this->assertErrorSummaries(['PHP']); $this->assertSession()->pageTextContains('Your PHP installation is too old. Drupal requires at least PHP ' . \Drupal::MINIMUM_SUPPORTED_PHP); } // Otherwise, there should be no error. else { $this->assertSession()->pageTextNotContains('Your PHP installation is too old. Drupal requires at least PHP ' . \Drupal::MINIMUM_SUPPORTED_PHP); $this->assertSession()->pageTextNotContains('Errors found'); } // There should be an informational message if the PHP version is below the // recommended version. if (version_compare($phpversion, \Drupal::RECOMMENDED_PHP) < 0) { $this->assertSession()->pageTextContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher'); } // Otherwise, the message should not be there. else { $this->assertSession()->pageTextNotContains('It is recommended to upgrade to PHP version ' . \Drupal::RECOMMENDED_PHP . ' or higher'); } } }
core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryErrorTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,15 @@ protected function setUpSettings() { // screen. } /** * {@inheritdoc} */ protected function setUpRequirementsProblem() { // The parent method asserts that there are no requirements errors, but // this test expects a requirements error in the test method below. // Therefore, we override this method to suppress the parent's assertions. } /** * {@inheritdoc} */ Loading
core/tests/Drupal/FunctionalTests/Installer/InstallerExistingBrokenDatabaseSettingsTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,15 @@ protected function setUpSettings() { // This form will never be reached. } /** * {@inheritdoc} */ protected function setUpRequirementsProblem() { // The parent method asserts that there are no requirements errors, but // this test expects a requirements error in the test method below. // Therefore, we override this method to suppress the parent's assertions. } /** * {@inheritdoc} */ Loading