3 namespace Drupal\Tests\system\Functional\System;
6 use Drupal\Tests\BrowserTestBase;
7 use Drupal\system\SystemRequirements;
8 use Symfony\Component\CssSelector\CssSelectorConverter;
11 * Tests output on the status overview page.
15 class StatusTest extends BrowserTestBase {
20 public static $modules = ['update_test_postupdate'];
25 protected function setUp() {
28 // Unset the sync directory in settings.php to trigger $config_directories
30 $settings['config_directories'] = [
31 CONFIG_SYNC_DIRECTORY => (object) [
36 $this->writeSettings($settings);
38 $admin_user = $this->drupalCreateUser([
39 'administer site configuration',
41 $this->drupalLogin($admin_user);
45 * Tests that the status page returns.
47 public function testStatusPage() {
48 // Go to Administration.
49 $this->drupalGet('admin/reports/status');
50 $this->assertResponse(200, 'The status page is reachable.');
52 $phpversion = phpversion();
53 $this->assertText($phpversion, 'Php version is shown on the page.');
55 // Checks if the suggestion to update to php 5.5.21 or 5.6.5 for disabling
56 // multiple statements is present when necessary.
57 if (\Drupal::database()->driver() === 'mysql' && !SystemRequirements::phpVersionWithPdoDisallowMultipleStatements($phpversion)) {
58 $this->assertText(t('PHP (multiple statement disabling)'));
61 $this->assertNoText(t('PHP (multiple statement disabling)'));
64 if (function_exists('phpinfo')) {
65 $this->assertLinkByHref(Url::fromRoute('system.php')->toString());
68 $this->assertNoLinkByHref(Url::fromRoute('system.php')->toString());
71 // If a module is fully installed no pending updates exists.
72 $this->assertNoText(t('Out of date'));
74 // The global $config_directories is not properly formed.
75 $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', ['%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY]));
77 // Set the schema version of update_test_postupdate to a lower version, so
78 // update_test_postupdate_update_8001() needs to be executed.
79 drupal_set_installed_schema_version('update_test_postupdate', 8000);
80 $this->drupalGet('admin/reports/status');
81 $this->assertText(t('Out of date'));
83 // Now cleanup the executed post update functions.
84 drupal_set_installed_schema_version('update_test_postupdate', 8001);
85 /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
86 $post_update_registry = \Drupal::service('update.post_update_registry');
87 $post_update_registry->filterOutInvokedUpdatesByModule('update_test_postupdate');
88 $this->drupalGet('admin/reports/status');
89 $this->assertText(t('Out of date'));
91 $this->drupalGet('admin/reports/status/php');
92 $this->assertResponse(200, 'The phpinfo page is reachable.');
94 // Check if cron error is displayed in errors section
95 $cron_last_run = \Drupal::state()->get('system.cron_last');
96 \Drupal::state()->set('system.cron_last', 0);
97 $this->drupalGet('admin/reports/status');
98 $css_selector_converter = new CssSelectorConverter();
99 $xpath = $css_selector_converter->toXPath('details.system-status-report__entry') . '//div[contains(text(), "Cron has not run recently")]';
100 $this->assertNotEmpty($this->xpath($xpath), 'Cron has not run recently error is being displayed.');
101 \Drupal::state()->set('system.cron_last', $cron_last_run);