diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index b0efbe5..945257a 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -378,6 +378,30 @@ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') { } /** + * Passes if a link containing a given href is not found in the main region. + * + * @param string $href + * The full or partial value of the 'href' attribute of the anchor tag. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use format_string() to embed variables in the message text, not + * t(). If left blank, a default message will be displayed. + * @param string $group + * (optional) The group this message is in, which is displayed in a column + * in test output. Use 'Debug' to indicate this is debugging output. Do not + * translate this string. Defaults to 'Other'; most tests do not override + * this default. + * + * @return bool + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertNoLinkByHrefInMainRegion($href, $message = '', $group = 'Other') { + $links = $this->xpath('//main//a[contains(@href, :href)]', array(':href' => $href)); + $message = ($message ? $message : SafeMarkup::format('No link containing href %href found.', array('%href' => $href))); + return $this->assert(empty($links), $message, $group); + } + + /** * Passes if the raw text IS found on the loaded page, fail otherwise. * * Raw text refers to the raw HTML that the page generated. diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 2a26ae0..6c177a2 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -390,11 +390,13 @@ protected function selection(Request $request) { * A render array. */ protected function results(Request $request) { + $base_url = str_replace('/update.php', '', $request->getBaseUrl()); + // Report end result. $dblog_exists = $this->moduleHandler->moduleExists('dblog'); if ($dblog_exists && $this->account->hasPermission('access site reports')) { $log_message = $this->t('All errors have been logged.', array( - '@url' => Url::fromRoute('dblog.overview')->toString(TRUE)->getGeneratedUrl(), + '@url' => Url::fromRoute('dblog.overview')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl(), )); } else { @@ -402,7 +404,7 @@ protected function results(Request $request) { } if (!empty($_SESSION['update_success'])) { - $message = '

' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your site. Otherwise, you may need to update your database manually.', array('@url' => Url::fromRoute('')->toString(TRUE)->getGeneratedUrl())) . ' ' . $log_message . '

'; + $message = '

' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your site. Otherwise, you may need to update your database manually.', array('@url' => Url::fromRoute('')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl())) . ' ' . $log_message . '

'; } else { $last = reset($_SESSION['updates_remaining']); diff --git a/core/modules/system/src/Tests/Update/UpdateScriptTest.php b/core/modules/system/src/Tests/Update/UpdateScriptTest.php index 7aed861..cba80ca 100644 --- a/core/modules/system/src/Tests/Update/UpdateScriptTest.php +++ b/core/modules/system/src/Tests/Update/UpdateScriptTest.php @@ -153,7 +153,7 @@ function testNoUpdateFunctionality() { $this->clickLink(t('Continue')); $this->assertText(t('No pending updates.')); $this->assertNoLink('Administration pages'); - $this->assertNoLinkByHref('update.php', 0); + $this->assertNoLinkByHrefInMainRegion('update.php', 0); $this->clickLink('Front page'); $this->assertResponse(200); @@ -164,7 +164,7 @@ function testNoUpdateFunctionality() { $this->clickLink(t('Continue')); $this->assertText(t('No pending updates.')); $this->assertLink('Administration pages'); - $this->assertNoLinkByHref('update.php', 1); + $this->assertNoLinkByHrefInMainRegion('update.php', 1); $this->clickLink('Administration pages'); $this->assertResponse(200); } @@ -198,7 +198,7 @@ function testSuccessfulUpdateFunctionality() { $this->assertText('Updates were attempted.'); $this->assertLink('logged'); $this->assertLink('Administration pages'); - $this->assertNoLinkByHref('update.php', 1); + $this->assertNoLinkByHrefInMainRegion('update.php', 1); $this->clickLink('Administration pages'); $this->assertResponse(200); } @@ -253,7 +253,7 @@ protected function updateScriptTest($maintenance_mode) { // Verify that there are no links to different parts of the workflow. $this->assertNoLink('Administration pages'); - $this->assertNoLinkByHref('update.php', 0); + $this->assertNoLinkByHrefInMainRegion('update.php', 0); $this->assertNoLink('logged'); // Verify the front page can be visited following the upgrade.