X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fupdate%2Ftests%2Fsrc%2FFunctional%2FUpdateTestBase.php;fp=web%2Fcore%2Fmodules%2Fupdate%2Ftests%2Fsrc%2FFunctional%2FUpdateTestBase.php;h=a4d07d0b682288230809868e72dda3a10623b2ef;hp=0000000000000000000000000000000000000000;hb=bfbba508964731508b9bd6d5835c2edc858db95b;hpb=cb9a80db11fc6b014e5b1e693a5a391c95eb5d9a diff --git a/web/core/modules/update/tests/src/Functional/UpdateTestBase.php b/web/core/modules/update/tests/src/Functional/UpdateTestBase.php new file mode 100644 index 000000000..a4d07d0b6 --- /dev/null +++ b/web/core/modules/update/tests/src/Functional/UpdateTestBase.php @@ -0,0 +1,84 @@ +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')); + } + +}