Skip to content
Snippets Groups Projects
Commit 7deab9ba authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3378793: Move error checking that should apply to all updates from cron...

Issue #3378793: Move error checking that should apply to all updates from cron build test to update assert
parent e82802c3
No related branches found
No related tags found
No related merge requests found
......@@ -201,43 +201,17 @@ class CoreUpdateTest extends UpdateTestBase {
$this->assertExpectedStageEventsFired(CronUpdateStage::class);
$this->assertSame(200, $cron_run_status_code);
// There should be log messages, but no errors or warnings should have been
// logged by Automatic Updates.
// The use of the database log here implies one can only retrieve log
// entries through the dblog UI. This seems non-ideal but it is the choice
// that requires least custom configuration or custom code. Using the
// `syslog` or `syslog_test` module or the `@RestResource=dblog` plugin for
// the `rest` module require more additional code than the inflexible log
// querying below.
$mink = $this->getMink();
$page = $mink->getSession()->getPage();
$assert_session = $mink->assertSession();
$this->visit('/admin/reports/dblog');
$assert_session->pageTextNotContains('No log messages available.');
$page->selectFieldOption('Type', 'automatic_updates');
$page->selectFieldOption('Severity', 'Emergency', TRUE);
$page->selectFieldOption('Severity', 'Alert', TRUE);
$page->selectFieldOption('Severity', 'Critical', TRUE);
$page->selectFieldOption('Severity', 'Warning', TRUE);
$page->pressButton('Filter');
$assert_session->pageTextContains('No log messages available.');
// Ensure that the update occurred.
// Ensure that the update was logged.
$page->selectFieldOption('Severity', 'Info');
$page->pressButton('Filter');
// There should be a log entry about the successful update.
$log_entry = $assert_session->elementExists('named', ['link', 'Drupal core has been updated from 9.8.0 to 9.8.1']);
$this->assertStringContainsString('/admin/reports/dblog/event/', $log_entry->getAttribute('href'));
$this->assertUpdateSuccessful('9.8.1');
// \Drupal\automatic_updates\Routing\RouteSubscriber::alterRoutes() sets
// `_automatic_updates_status_messages: skip` on the route for the path
// `/admin/modules/reports/status`, but not on the `/admin/reports` path. So
// to test AdminStatusCheckMessages::displayAdminPageMessages(), another
// page must be visited. `/admin/reports` was chosen, but it could be
// another too.
$assert_session->addressEquals('/admin/reports/status');
$this->visit('/admin/reports');
$assert_session->statusCodeEquals(200);
// @see \Drupal\automatic_updates\Validation\AdminStatusCheckMessages::displayAdminPageMessages()
$this->webAssert->statusMessageNotExists('error');
$this->webAssert->statusMessageNotExists('warning');
}
/**
......@@ -311,6 +285,46 @@ class CoreUpdateTest extends UpdateTestBase {
* The expected active version of Drupal core.
*/
private function assertUpdateSuccessful(string $expected_version): void {
$mink = $this->getMink();
$page = $mink->getSession()->getPage();
$assert_session = $mink->assertSession();
// There should be log messages, but no errors or warnings should have been
// logged by Automatic Updates.
// The use of the database log here implies one can only retrieve log
// entries through the dblog UI. This seems non-ideal but it is the choice
// that requires least custom configuration or custom code. Using the
// `syslog` or `syslog_test` module or the `@RestResource=dblog` plugin for
// the `rest` module require more additional code than the inflexible log
// querying below.
$this->visit('/admin/reports/dblog');
$type_select_field = $assert_session->fieldExists('Type');
// Automatic Updates may not have logged any entries but if it did there
// should not have been any errors or warnings.
if ($type_select_field->find('named', ['option', 'automatic_updates'])) {
$assert_session->pageTextNotContains('No log messages available.');
$page->selectFieldOption('Type', 'automatic_updates');
$page->selectFieldOption('Severity', 'Emergency', TRUE);
$page->selectFieldOption('Severity', 'Alert', TRUE);
$page->selectFieldOption('Severity', 'Critical', TRUE);
$page->selectFieldOption('Severity', 'Warning', TRUE);
$page->pressButton('Filter');
$assert_session->pageTextContains('No log messages available.');
}
// \Drupal\automatic_updates\Routing\RouteSubscriber::alterRoutes() sets
// `_automatic_updates_status_messages: skip` on the route for the path
// `/admin/modules/reports/status`, but not on the `/admin/reports` path. So
// to test AdminStatusCheckMessages::displayAdminPageMessages(), another
// page must be visited. `/admin/reports` was chosen, but it could be
// another too.
$this->visit('/admin/reports');
$assert_session->statusCodeEquals(200);
// @see \Drupal\automatic_updates\Validation\AdminStatusCheckMessages::displayAdminPageMessages()
$this->webAssert->statusMessageNotExists('error');
$this->webAssert->statusMessageNotExists('warning');
$web_root = $this->getWebRoot();
$placeholder = file_get_contents("$web_root/core/README.txt");
$this->assertSame("Placeholder for Drupal core $expected_version.", $placeholder);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment