diff --git a/core/modules/update/src/Tests/UpdateTestBase.php b/core/modules/update/src/Tests/UpdateTestBase.php index fc39d1a..7f576c9 100644 --- a/core/modules/update/src/Tests/UpdateTestBase.php +++ b/core/modules/update/src/Tests/UpdateTestBase.php @@ -58,7 +58,7 @@ protected function setUp() { * (optional) A string containing the URL to fetch update data from. * Defaults to 'update-test'. * - * @see Drupal\update_test\Controller\UpdateTestController::updateTest() + * @see \Drupal\update_test\Controller\UpdateTestController::updateTest() */ protected function refreshUpdateStatus($xml_map, $url = 'update-test') { // Tell the Update Manager module to fetch from the URL provided by diff --git a/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php similarity index 92% rename from core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php rename to core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php index 9d1819f..d768b06 100644 --- a/core/modules/update/src/Tests/FileTransferAuthorizeFormTest.php +++ b/core/modules/update/tests/src/Functional/FileTransferAuthorizeFormTest.php @@ -1,6 +1,6 @@ standardTests(); $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); $this->assertNoText(t('Security update required!')); $this->assertRaw(\Drupal::l("8.$minor_version.1" . $extra_version, Url::fromUri("http://example.com/drupal-8-$minor_version-1$extra_version-release")), 'Link to release appears.'); $this->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-8-$minor_version-1$extra_version.tar.gz")), 'Link to download appears.'); @@ -139,6 +143,7 @@ public function testMajorUpdateAvailable() { $this->standardTests(); $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); $this->assertNoText(t('Security update required!')); $this->assertRaw(\Drupal::l('9.0.0', Url::fromUri("http://example.com/drupal-9-0-0-release")), 'Link to release appears.'); $this->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-9-0-0.tar.gz")), 'Link to download appears.'); @@ -226,6 +231,7 @@ public function testModulePageUpToDate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); $this->assertText(t('Checked available update data for one project.')); $this->drupalGet('admin/modules'); $this->assertNoText(t('There are updates available for your version of Drupal.')); @@ -247,6 +253,7 @@ public function testModulePageRegularUpdate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); $this->assertText(t('Checked available update data for one project.')); $this->drupalGet('admin/modules'); $this->assertText(t('There are updates available for your version of Drupal.')); @@ -268,6 +275,7 @@ public function testModulePageSecurityUpdate() { $this->drupalGet('admin/reports/updates'); $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); $this->assertText(t('Checked available update data for one project.')); $this->drupalGet('admin/modules'); $this->assertNoText(t('There are updates available for your version of Drupal.')); diff --git a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php b/core/modules/update/tests/src/Functional/UpdateDeleteFileIfStaleTest.php similarity index 96% rename from core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php rename to core/modules/update/tests/src/Functional/UpdateDeleteFileIfStaleTest.php index 99499d7..601a6cc 100644 --- a/core/modules/update/src/Tests/UpdateDeleteFileIfStaleTest.php +++ b/core/modules/update/tests/src/Functional/UpdateDeleteFileIfStaleTest.php @@ -1,6 +1,6 @@ container->get('update.root') . '/' . DrupalKernel::findSitePath($request); + $this->container->set('update.root', $update_root); + \Drupal::setContainer($this->container); + + // Create the directories within the root path within which the Update + // Manager will install projects. + foreach (drupal_get_updaters() as $updater_info) { + $updater = $updater_info['class']; + $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath(); + if (!is_dir($install_directory)) { + mkdir($install_directory); + } + } + } + + /** + * Refreshes the update status based on the desired available update scenario. + * + * @param $xml_map + * Array that maps project names to availability scenarios to fetch. The key + * '#all' is used if a project-specific mapping is not defined. + * @param $url + * (optional) A string containing the URL to fetch update data from. + * Defaults to 'update-test'. + * + * @see \Drupal\update_test\Controller\UpdateTestController::updateTest() + */ + protected function refreshUpdateStatus($xml_map, $url = 'update-test') { + // Tell the Update Manager module to fetch from the URL provided by + // update_test module. + $this->config('update.settings')->set('fetch.url', Url::fromUri('base:' . $url, ['absolute' => TRUE])->toString())->save(); + // Save the map for UpdateTestController::updateTest() to use. + $this->config('update_test.settings')->set('xml_map', $xml_map)->save(); + // Manually check the update status. + $this->drupalGet('admin/reports/updates'); + $this->clickLink(t('Check manually')); + $this->checkForMetaRefresh(); + } + + /** + * Runs a series of assertions that are applicable to all update statuses. + */ + protected function standardTests() { + $this->assertRaw('

' . t('Drupal core') . '

'); + $this->assertRaw(\Drupal::l(t('Drupal'), Url::fromUri('http://example.com/project/drupal')), 'Link to the Drupal project appears.'); + $this->assertNoText(t('No available releases found')); + } + +} diff --git a/core/modules/update/src/Tests/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php similarity index 96% rename from core/modules/update/src/Tests/UpdateUploadTest.php rename to core/modules/update/tests/src/Functional/UpdateUploadTest.php index 80d3f15..6096620 100644 --- a/core/modules/update/src/Tests/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -1,10 +1,11 @@ $validArchiveFile, ]; @@ -63,7 +68,7 @@ public function testUploadModule() { $moduleUpdater = $updaters['module']['class']; $installedInfoFilePath = $this->container->get('update.root') . '/' . $moduleUpdater::getRootDirectoryRelativePath() . '/update_test_new_module/update_test_new_module.info.yml'; $this->assertFalse(file_exists($installedInfoFilePath), 'The new module does not exist in the filesystem before it is installed with the Update Manager.'); - $validArchiveFile = __DIR__ . '/../../tests/update_test_new_module/8.x-1.0/update_test_new_module.tar.gz'; + $validArchiveFile = __DIR__ . '/../../update_test_new_module/8.x-1.0/update_test_new_module.tar.gz'; $edit = [ 'files[project_upload]' => $validArchiveFile, ];