annotate core/modules/update/tests/src/Functional/UpdateContribTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\update\Functional;
Chris@0 4
Chris@0 5 use Drupal\Core\Url;
Chris@0 6 use Drupal\Core\Utility\ProjectInfo;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Tests how the Update Manager module handles contributed modules and themes in
Chris@0 10 * a series of functional tests using mock XML data.
Chris@0 11 *
Chris@0 12 * @group update
Chris@0 13 */
Chris@0 14 class UpdateContribTest extends UpdateTestBase {
Chris@0 15
Chris@0 16 /**
Chris@0 17 * Modules to enable.
Chris@0 18 *
Chris@0 19 * @var array
Chris@0 20 */
Chris@0 21 public static $modules = ['update_test', 'update', 'aaa_update_test', 'bbb_update_test', 'ccc_update_test'];
Chris@0 22
Chris@0 23 protected function setUp() {
Chris@0 24 parent::setUp();
Chris@0 25 $admin_user = $this->drupalCreateUser(['administer site configuration']);
Chris@0 26 $this->drupalLogin($admin_user);
Chris@0 27 }
Chris@0 28
Chris@0 29 /**
Chris@0 30 * Tests when there is no available release data for a contrib module.
Chris@0 31 */
Chris@0 32 public function testNoReleasesAvailable() {
Chris@0 33 $system_info = [
Chris@0 34 '#all' => [
Chris@0 35 'version' => '8.0.0',
Chris@0 36 ],
Chris@0 37 'aaa_update_test' => [
Chris@0 38 'project' => 'aaa_update_test',
Chris@0 39 'version' => '8.x-1.0',
Chris@0 40 'hidden' => FALSE,
Chris@0 41 ],
Chris@0 42 ];
Chris@0 43 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 44 $this->refreshUpdateStatus(['drupal' => '0.0', 'aaa_update_test' => 'no-releases']);
Chris@0 45 $this->drupalGet('admin/reports/updates');
Chris@0 46 // Cannot use $this->standardTests() because we need to check for the
Chris@0 47 // 'No available releases found' string.
Chris@0 48 $this->assertRaw('<h3>' . t('Drupal core') . '</h3>');
Chris@0 49 $this->assertRaw(\Drupal::l(t('Drupal'), Url::fromUri('http://example.com/project/drupal')));
Chris@0 50 $this->assertText(t('Up to date'));
Chris@0 51 $this->assertRaw('<h3>' . t('Modules') . '</h3>');
Chris@0 52 $this->assertNoText(t('Update available'));
Chris@0 53 $this->assertText(t('No available releases found'));
Chris@0 54 $this->assertNoRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')));
Chris@0 55
Chris@0 56 $available = update_get_available();
Chris@0 57 $this->assertFalse(isset($available['aaa_update_test']['fetch_status']), 'Results are cached even if no releases are available.');
Chris@0 58 }
Chris@0 59
Chris@0 60 /**
Chris@0 61 * Tests the basic functionality of a contrib module on the status report.
Chris@0 62 */
Chris@0 63 public function testUpdateContribBasic() {
Chris@0 64 $project_link = \Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'));
Chris@0 65 $system_info = [
Chris@0 66 '#all' => [
Chris@0 67 'version' => '8.0.0',
Chris@0 68 ],
Chris@0 69 'aaa_update_test' => [
Chris@0 70 'project' => 'aaa_update_test',
Chris@0 71 'version' => '8.x-1.0',
Chris@0 72 'hidden' => FALSE,
Chris@0 73 ],
Chris@0 74 ];
Chris@0 75 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 76 $this->refreshUpdateStatus(
Chris@0 77 [
Chris@0 78 'drupal' => '0.0',
Chris@0 79 'aaa_update_test' => '1_0',
Chris@0 80 ]
Chris@0 81 );
Chris@0 82 $this->standardTests();
Chris@0 83 $this->assertText(t('Up to date'));
Chris@0 84 $this->assertRaw('<h3>' . t('Modules') . '</h3>');
Chris@0 85 $this->assertNoText(t('Update available'));
Chris@0 86 $this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
Chris@0 87
Chris@0 88 // Since aaa_update_test is installed the fact it is hidden and in the
Chris@0 89 // Testing package means it should not appear.
Chris@0 90 $system_info['aaa_update_test']['hidden'] = TRUE;
Chris@0 91 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 92 $this->refreshUpdateStatus(
Chris@0 93 [
Chris@0 94 'drupal' => '0.0',
Chris@0 95 'aaa_update_test' => '1_0',
Chris@0 96 ]
Chris@0 97 );
Chris@0 98 $this->assertNoRaw($project_link, 'Link to aaa_update_test project does not appear.');
Chris@0 99
Chris@0 100 // A hidden and installed project not in the Testing package should appear.
Chris@0 101 $system_info['aaa_update_test']['package'] = 'aaa_update_test';
Chris@0 102 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 103 $this->refreshUpdateStatus(
Chris@0 104 [
Chris@0 105 'drupal' => '0.0',
Chris@0 106 'aaa_update_test' => '1_0',
Chris@0 107 ]
Chris@0 108 );
Chris@0 109 $this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
Chris@0 110 }
Chris@0 111
Chris@0 112 /**
Chris@0 113 * Tests that contrib projects are ordered by project name.
Chris@0 114 *
Chris@0 115 * If a project contains multiple modules, we want to make sure that the
Chris@0 116 * available updates report is sorted by the parent project names, not by the
Chris@0 117 * names of the modules included in each project. In this test case, we have
Chris@0 118 * two contrib projects, "BBB Update test" and "CCC Update test". However, we
Chris@0 119 * have a module called "aaa_update_test" that's part of the "CCC Update test"
Chris@0 120 * project. We need to make sure that we see the "BBB" project before the
Chris@0 121 * "CCC" project, even though "CCC" includes a module that's processed first
Chris@0 122 * if you sort alphabetically by module name (which is the order we see things
Chris@0 123 * inside system_rebuild_module_data() for example).
Chris@0 124 */
Chris@0 125 public function testUpdateContribOrder() {
Chris@0 126 // We want core to be version 8.0.0.
Chris@0 127 $system_info = [
Chris@0 128 '#all' => [
Chris@0 129 'version' => '8.0.0',
Chris@0 130 ],
Chris@0 131 // All the rest should be visible as contrib modules at version 8.x-1.0.
Chris@0 132
Chris@0 133 // aaa_update_test needs to be part of the "CCC Update test" project,
Chris@0 134 // which would throw off the report if we weren't properly sorting by
Chris@0 135 // the project names.
Chris@0 136 'aaa_update_test' => [
Chris@0 137 'project' => 'ccc_update_test',
Chris@0 138 'version' => '8.x-1.0',
Chris@0 139 'hidden' => FALSE,
Chris@0 140 ],
Chris@0 141
Chris@0 142 // This should be its own project, and listed first on the report.
Chris@0 143 'bbb_update_test' => [
Chris@0 144 'project' => 'bbb_update_test',
Chris@0 145 'version' => '8.x-1.0',
Chris@0 146 'hidden' => FALSE,
Chris@0 147 ],
Chris@0 148
Chris@0 149 // This will contain both aaa_update_test and ccc_update_test, and
Chris@0 150 // should come after the bbb_update_test project.
Chris@0 151 'ccc_update_test' => [
Chris@0 152 'project' => 'ccc_update_test',
Chris@0 153 'version' => '8.x-1.0',
Chris@0 154 'hidden' => FALSE,
Chris@0 155 ],
Chris@0 156 ];
Chris@0 157 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 158 $this->refreshUpdateStatus(['drupal' => '0.0', '#all' => '1_0']);
Chris@0 159 $this->standardTests();
Chris@0 160 // We're expecting the report to say all projects are up to date.
Chris@0 161 $this->assertText(t('Up to date'));
Chris@0 162 $this->assertNoText(t('Update available'));
Chris@0 163 // We want to see all 3 module names listed, since they'll show up either
Chris@0 164 // as project names or as modules under the "Includes" listing.
Chris@0 165 $this->assertText(t('AAA Update test'));
Chris@0 166 $this->assertText(t('BBB Update test'));
Chris@0 167 $this->assertText(t('CCC Update test'));
Chris@0 168 // We want aaa_update_test included in the ccc_update_test project, not as
Chris@0 169 // its own project on the report.
Chris@0 170 $this->assertNoRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project does not appear.');
Chris@0 171 // The other two should be listed as projects.
Chris@0 172 $this->assertRaw(\Drupal::l(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test')), 'Link to bbb_update_test project appears.');
Chris@0 173 $this->assertRaw(\Drupal::l(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test')), 'Link to bbb_update_test project appears.');
Chris@0 174
Chris@0 175 // We want to make sure we see the BBB project before the CCC project.
Chris@0 176 // Instead of just searching for 'BBB Update test' or something, we want
Chris@0 177 // to use the full markup that starts the project entry itself, so that
Chris@0 178 // we're really testing that the project listings are in the right order.
Chris@0 179 $bbb_project_link = '<div class="project-update__title"><a href="http://example.com/project/bbb_update_test">BBB Update test</a>';
Chris@0 180 $ccc_project_link = '<div class="project-update__title"><a href="http://example.com/project/ccc_update_test">CCC Update test</a>';
Chris@17 181 $this->assertTrue(strpos($this->getSession()->getPage()->getContent(), $bbb_project_link) < strpos($this->getSession()->getPage()->getContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project");
Chris@0 182 }
Chris@0 183
Chris@0 184 /**
Chris@0 185 * Tests that subthemes are notified about security updates for base themes.
Chris@0 186 */
Chris@0 187 public function testUpdateBaseThemeSecurityUpdate() {
Chris@0 188 // @todo https://www.drupal.org/node/2338175 base themes have to be
Chris@0 189 // installed.
Chris@0 190 // Only install the subtheme, not the base theme.
Chris@0 191 \Drupal::service('theme_handler')->install(['update_test_subtheme']);
Chris@0 192
Chris@0 193 // Define the initial state for core and the subtheme.
Chris@0 194 $system_info = [
Chris@0 195 // We want core to be version 8.0.0.
Chris@0 196 '#all' => [
Chris@0 197 'version' => '8.0.0',
Chris@0 198 ],
Chris@0 199 // Show the update_test_basetheme
Chris@0 200 'update_test_basetheme' => [
Chris@0 201 'project' => 'update_test_basetheme',
Chris@0 202 'version' => '8.x-1.0',
Chris@0 203 'hidden' => FALSE,
Chris@0 204 ],
Chris@0 205 // Show the update_test_subtheme
Chris@0 206 'update_test_subtheme' => [
Chris@0 207 'project' => 'update_test_subtheme',
Chris@0 208 'version' => '8.x-1.0',
Chris@0 209 'hidden' => FALSE,
Chris@0 210 ],
Chris@0 211 ];
Chris@0 212 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 213 $xml_mapping = [
Chris@0 214 'drupal' => '0.0',
Chris@0 215 'update_test_subtheme' => '1_0',
Chris@0 216 'update_test_basetheme' => '1_1-sec',
Chris@0 217 ];
Chris@0 218 $this->refreshUpdateStatus($xml_mapping);
Chris@0 219 $this->assertText(t('Security update required!'));
Chris@0 220 $this->assertRaw(\Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme')), 'Link to the Update test base theme project appears.');
Chris@0 221 }
Chris@0 222
Chris@0 223 /**
Chris@0 224 * Tests that disabled themes are only shown when desired.
Chris@0 225 *
Chris@0 226 * @todo https://www.drupal.org/node/2338175 extensions can not be hidden and
Chris@0 227 * base themes have to be installed.
Chris@0 228 */
Chris@0 229 public function testUpdateShowDisabledThemes() {
Chris@0 230 $update_settings = $this->config('update.settings');
Chris@0 231 // Make sure all the update_test_* themes are disabled.
Chris@0 232 $extension_config = $this->config('core.extension');
Chris@0 233 foreach ($extension_config->get('theme') as $theme => $weight) {
Chris@0 234 if (preg_match('/^update_test_/', $theme)) {
Chris@0 235 $extension_config->clear("theme.$theme");
Chris@0 236 }
Chris@0 237 }
Chris@0 238 $extension_config->save();
Chris@0 239
Chris@0 240 // Define the initial state for core and the test contrib themes.
Chris@0 241 $system_info = [
Chris@0 242 // We want core to be version 8.0.0.
Chris@0 243 '#all' => [
Chris@0 244 'version' => '8.0.0',
Chris@0 245 ],
Chris@0 246 // The update_test_basetheme should be visible and up to date.
Chris@0 247 'update_test_basetheme' => [
Chris@0 248 'project' => 'update_test_basetheme',
Chris@0 249 'version' => '8.x-1.1',
Chris@0 250 'hidden' => FALSE,
Chris@0 251 ],
Chris@0 252 // The update_test_subtheme should be visible and up to date.
Chris@0 253 'update_test_subtheme' => [
Chris@0 254 'project' => 'update_test_subtheme',
Chris@0 255 'version' => '8.x-1.0',
Chris@0 256 'hidden' => FALSE,
Chris@0 257 ],
Chris@0 258 ];
Chris@0 259 // When there are contributed modules in the site's file system, the
Chris@0 260 // total number of attempts made in the test may exceed the default value
Chris@0 261 // of update_max_fetch_attempts. Therefore this variable is set very high
Chris@0 262 // to avoid test failures in those cases.
Chris@0 263 $update_settings->set('fetch.max_attempts', 99999)->save();
Chris@0 264 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 265 $xml_mapping = [
Chris@0 266 'drupal' => '0.0',
Chris@0 267 'update_test_subtheme' => '1_0',
Chris@0 268 'update_test_basetheme' => '1_1-sec',
Chris@0 269 ];
Chris@0 270 $base_theme_project_link = \Drupal::l(t('Update test base theme'), Url::fromUri('http://example.com/project/update_test_basetheme'));
Chris@0 271 $sub_theme_project_link = \Drupal::l(t('Update test subtheme'), Url::fromUri('http://example.com/project/update_test_subtheme'));
Chris@0 272 foreach ([TRUE, FALSE] as $check_disabled) {
Chris@0 273 $update_settings->set('check.disabled_extensions', $check_disabled)->save();
Chris@0 274 $this->refreshUpdateStatus($xml_mapping);
Chris@0 275 // In neither case should we see the "Themes" heading for installed
Chris@0 276 // themes.
Chris@0 277 $this->assertNoText(t('Themes'));
Chris@0 278 if ($check_disabled) {
Chris@0 279 $this->assertText(t('Uninstalled themes'));
Chris@0 280 $this->assertRaw($base_theme_project_link, 'Link to the Update test base theme project appears.');
Chris@0 281 $this->assertRaw($sub_theme_project_link, 'Link to the Update test subtheme project appears.');
Chris@0 282 }
Chris@0 283 else {
Chris@0 284 $this->assertNoText(t('Uninstalled themes'));
Chris@0 285 $this->assertNoRaw($base_theme_project_link, 'Link to the Update test base theme project does not appear.');
Chris@0 286 $this->assertNoRaw($sub_theme_project_link, 'Link to the Update test subtheme project does not appear.');
Chris@0 287 }
Chris@0 288 }
Chris@0 289 }
Chris@0 290
Chris@0 291 /**
Chris@0 292 * Tests updates with a hidden base theme.
Chris@0 293 */
Chris@0 294 public function testUpdateHiddenBaseTheme() {
Chris@0 295 module_load_include('compare.inc', 'update');
Chris@0 296
Chris@0 297 // Install the subtheme.
Chris@0 298 \Drupal::service('theme_handler')->install(['update_test_subtheme']);
Chris@0 299
Chris@0 300 // Add a project and initial state for base theme and subtheme.
Chris@0 301 $system_info = [
Chris@0 302 // Hide the update_test_basetheme.
Chris@0 303 'update_test_basetheme' => [
Chris@0 304 'project' => 'update_test_basetheme',
Chris@0 305 'hidden' => TRUE,
Chris@0 306 ],
Chris@0 307 // Show the update_test_subtheme.
Chris@0 308 'update_test_subtheme' => [
Chris@0 309 'project' => 'update_test_subtheme',
Chris@0 310 'hidden' => FALSE,
Chris@0 311 ],
Chris@0 312 ];
Chris@0 313 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 314 $projects = \Drupal::service('update.manager')->getProjects();
Chris@0 315 $theme_data = \Drupal::service('theme_handler')->rebuildThemeData();
Chris@0 316 $project_info = new ProjectInfo();
Chris@0 317 $project_info->processInfoList($projects, $theme_data, 'theme', TRUE);
Chris@0 318
Chris@0 319 $this->assertTrue(!empty($projects['update_test_basetheme']), 'Valid base theme (update_test_basetheme) was found.');
Chris@0 320 }
Chris@0 321
Chris@0 322 /**
Chris@0 323 * Makes sure that if we fetch from a broken URL, sane things happen.
Chris@0 324 */
Chris@0 325 public function testUpdateBrokenFetchURL() {
Chris@0 326 $system_info = [
Chris@0 327 '#all' => [
Chris@0 328 'version' => '8.0.0',
Chris@0 329 ],
Chris@0 330 'aaa_update_test' => [
Chris@0 331 'project' => 'aaa_update_test',
Chris@0 332 'version' => '8.x-1.0',
Chris@0 333 'hidden' => FALSE,
Chris@0 334 ],
Chris@0 335 'bbb_update_test' => [
Chris@0 336 'project' => 'bbb_update_test',
Chris@0 337 'version' => '8.x-1.0',
Chris@0 338 'hidden' => FALSE,
Chris@0 339 ],
Chris@0 340 'ccc_update_test' => [
Chris@0 341 'project' => 'ccc_update_test',
Chris@0 342 'version' => '8.x-1.0',
Chris@0 343 'hidden' => FALSE,
Chris@0 344 ],
Chris@0 345 ];
Chris@0 346 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@0 347
Chris@0 348 // Ensure that the update information is correct before testing.
Chris@0 349 $this->drupalGet('admin/reports/updates');
Chris@0 350
Chris@0 351 $xml_mapping = [
Chris@0 352 'drupal' => '0.0',
Chris@0 353 'aaa_update_test' => '1_0',
Chris@0 354 'bbb_update_test' => 'does-not-exist',
Chris@0 355 'ccc_update_test' => '1_0',
Chris@0 356 ];
Chris@0 357 $this->refreshUpdateStatus($xml_mapping);
Chris@0 358
Chris@0 359 $this->assertText(t('Up to date'));
Chris@0 360 // We're expecting the report to say most projects are up to date, so we
Chris@0 361 // hope that 'Up to date' is not unique.
Chris@0 362 $this->assertNoUniqueText(t('Up to date'));
Chris@0 363 // It should say we failed to get data, not that we're missing an update.
Chris@0 364 $this->assertNoText(t('Update available'));
Chris@0 365
Chris@0 366 // We need to check that this string is found as part of a project row, not
Chris@0 367 // just in the "Failed to get available update data" message at the top of
Chris@0 368 // the page.
Chris@0 369 $this->assertRaw('<div class="project-update__status">' . t('Failed to get available update data'));
Chris@0 370
Chris@0 371 // We should see the output messages from fetching manually.
Chris@0 372 $this->assertUniqueText(t('Checked available update data for 3 projects.'));
Chris@0 373 $this->assertUniqueText(t('Failed to get available update data for one project.'));
Chris@0 374
Chris@0 375 // The other two should be listed as projects.
Chris@0 376 $this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
Chris@0 377 $this->assertNoRaw(\Drupal::l(t('BBB Update test'), Url::fromUri('http://example.com/project/bbb_update_test')), 'Link to bbb_update_test project does not appear.');
Chris@0 378 $this->assertRaw(\Drupal::l(t('CCC Update test'), Url::fromUri('http://example.com/project/ccc_update_test')), 'Link to bbb_update_test project appears.');
Chris@0 379 }
Chris@0 380
Chris@0 381 /**
Chris@0 382 * Checks that hook_update_status_alter() works to change a status.
Chris@0 383 *
Chris@0 384 * We provide the same external data as if aaa_update_test 8.x-1.0 were
Chris@0 385 * installed and that was the latest release. Then we use
Chris@0 386 * hook_update_status_alter() to try to mark this as missing a security
Chris@0 387 * update, then assert if we see the appropriate warnings on the right pages.
Chris@0 388 */
Chris@0 389 public function testHookUpdateStatusAlter() {
Chris@0 390 $update_test_config = $this->config('update_test.settings');
Chris@0 391 $update_admin_user = $this->drupalCreateUser(['administer site configuration', 'administer software updates']);
Chris@0 392 $this->drupalLogin($update_admin_user);
Chris@0 393
Chris@0 394 $system_info = [
Chris@0 395 '#all' => [
Chris@0 396 'version' => '8.0.0',
Chris@0 397 ],
Chris@0 398 'aaa_update_test' => [
Chris@0 399 'project' => 'aaa_update_test',
Chris@0 400 'version' => '8.x-1.0',
Chris@0 401 'hidden' => FALSE,
Chris@0 402 ],
Chris@0 403 ];
Chris@0 404 $update_test_config->set('system_info', $system_info)->save();
Chris@0 405 $update_status = [
Chris@0 406 'aaa_update_test' => [
Chris@0 407 'status' => UPDATE_NOT_SECURE,
Chris@0 408 ],
Chris@0 409 ];
Chris@0 410 $update_test_config->set('update_status', $update_status)->save();
Chris@0 411 $this->refreshUpdateStatus(
Chris@0 412 [
Chris@0 413 'drupal' => '0.0',
Chris@0 414 'aaa_update_test' => '1_0',
Chris@0 415 ]
Chris@0 416 );
Chris@0 417 $this->drupalGet('admin/reports/updates');
Chris@0 418 $this->assertRaw('<h3>' . t('Modules') . '</h3>');
Chris@0 419 $this->assertText(t('Security update required!'));
Chris@0 420 $this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
Chris@0 421
Chris@0 422 // Visit the reports page again without the altering and make sure the
Chris@0 423 // status is back to normal.
Chris@0 424 $update_test_config->set('update_status', [])->save();
Chris@0 425 $this->drupalGet('admin/reports/updates');
Chris@0 426 $this->assertRaw('<h3>' . t('Modules') . '</h3>');
Chris@0 427 $this->assertNoText(t('Security update required!'));
Chris@0 428 $this->assertRaw(\Drupal::l(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test')), 'Link to aaa_update_test project appears.');
Chris@0 429
Chris@0 430 // Turn the altering back on and visit the Update manager UI.
Chris@0 431 $update_test_config->set('update_status', $update_status)->save();
Chris@0 432 $this->drupalGet('admin/modules/update');
Chris@0 433 $this->assertText(t('Security update'));
Chris@0 434
Chris@0 435 // Turn the altering back off and visit the Update manager UI.
Chris@0 436 $update_test_config->set('update_status', [])->save();
Chris@0 437 $this->drupalGet('admin/modules/update');
Chris@0 438 $this->assertNoText(t('Security update'));
Chris@0 439 }
Chris@0 440
Chris@17 441 /**
Chris@17 442 * Tests update status of security releases.
Chris@17 443 *
Chris@17 444 * @param string $module_version
Chris@17 445 * The module version the site is using.
Chris@17 446 * @param string[] $expected_security_releases
Chris@17 447 * The security releases, if any, that the status report should recommend.
Chris@17 448 * @param string $expected_update_message_type
Chris@17 449 * The type of update message expected.
Chris@17 450 * @param string $fixture
Chris@17 451 * The fixture file to use.
Chris@17 452 *
Chris@17 453 * @dataProvider securityUpdateAvailabilityProvider
Chris@17 454 */
Chris@17 455 public function testSecurityUpdateAvailability($module_version, array $expected_security_releases, $expected_update_message_type, $fixture) {
Chris@17 456 $system_info = [
Chris@17 457 '#all' => [
Chris@17 458 'version' => '8.0.0',
Chris@17 459 ],
Chris@17 460 'aaa_update_test' => [
Chris@17 461 'project' => 'aaa_update_test',
Chris@17 462 'version' => $module_version,
Chris@17 463 'hidden' => FALSE,
Chris@17 464 ],
Chris@17 465 ];
Chris@17 466 $this->config('update_test.settings')->set('system_info', $system_info)->save();
Chris@17 467 $this->refreshUpdateStatus(['drupal' => '0.0', 'aaa_update_test' => $fixture]);
Chris@17 468 $this->assertSecurityUpdates('aaa_update_test', $expected_security_releases, $expected_update_message_type, 'table.update:nth-of-type(2)');
Chris@17 469 }
Chris@17 470
Chris@17 471 /**
Chris@17 472 * Data provider method for testSecurityUpdateAvailability().
Chris@17 473 *
Chris@17 474 * These test cases rely on the following fixtures containing the following
Chris@17 475 * releases:
Chris@17 476 * - aaa_update_test.sec.8.x-1.2.xml
Chris@17 477 * - 8.x-1.2 Security update
Chris@17 478 * - 8.x-1.1 Insecure
Chris@17 479 * - 8.x-1.0 Insecure
Chris@17 480 * - aaa_update_test.sec.8.x-1.1_8.x-1.2.xml
Chris@17 481 * - 8.x-1.2 Security update
Chris@17 482 * - 8.x-1.1 Security update, Insecure
Chris@17 483 * - 8.x-1.0 Insecure
Chris@17 484 * - aaa_update_test.sec.8.x-1.2_8.x-2.2.xml
Chris@17 485 * - 8.x-3.0-beta2
Chris@17 486 * - 8.x-3.0-beta1 Insecure
Chris@17 487 * - 8.x-2.2 Security update
Chris@17 488 * - 8.x-2.1 Security update, Insecure
Chris@17 489 * - 8.x-2.0 Insecure
Chris@17 490 * - 8.x-1.2 Security update
Chris@17 491 * - 8.x-1.1 Insecure
Chris@17 492 * - 8.x-1.0 Insecure
Chris@17 493 * - aaa_update_test.sec.8.x-2.2_1.x_secure.xml
Chris@17 494 * - 8.x-2.2 Security update
Chris@17 495 * - 8.x-2.1 Security update, Insecure
Chris@17 496 * - 8.x-2.0 Insecure
Chris@17 497 * - 8.x-1.2
Chris@17 498 * - 8.x-1.1
Chris@17 499 * - 8.x-1.0
Chris@17 500 */
Chris@17 501 public function securityUpdateAvailabilityProvider() {
Chris@17 502 return [
Chris@17 503 // Security releases available for module major release 1.
Chris@17 504 // No releases for next major.
Chris@17 505 '8.x-1.0, 8.x-1.2' => [
Chris@17 506 'module_patch_version' => '8.x-1.0',
Chris@17 507 'expected_security_releases' => ['8.x-1.2'],
Chris@17 508 'expected_update_message_type' => static::SECURITY_UPDATE_REQUIRED,
Chris@17 509 'fixture' => 'sec.8.x-1.2',
Chris@17 510 ],
Chris@17 511 // Two security releases available for module major release 1.
Chris@17 512 // 8.x-1.1 security release marked as insecure.
Chris@17 513 // No releases for next major.
Chris@17 514 '8.x-1.0, 8.x-1.1 8.x-1.2' => [
Chris@17 515 'module_patch_version' => '8.x-1.0',
Chris@17 516 'expected_security_releases' => ['8.x-1.2'],
Chris@17 517 'expected_update_message_type' => static::SECURITY_UPDATE_REQUIRED,
Chris@17 518 'fixture' => 'sec.8.x-1.1_8.x-1.2',
Chris@17 519 ],
Chris@17 520 // Security release available for module major release 2.
Chris@17 521 // No releases for next major.
Chris@17 522 '8.x-2.0, 8.x-2.2' => [
Chris@17 523 'module_patch_version' => '8.x-2.0',
Chris@17 524 'expected_security_releases' => ['8.x-2.2'],
Chris@17 525 'expected_update_message_type' => static::SECURITY_UPDATE_REQUIRED,
Chris@17 526 'fixture' => 'sec.8.x-2.2_1.x_secure',
Chris@17 527 ],
Chris@17 528 '8.x-2.2, 8.x-1.2 8.x-2.2' => [
Chris@17 529 'module_patch_version' => '8.x-2.2',
Chris@17 530 'expected_security_releases' => [],
Chris@17 531 'expected_update_message_type' => static::UPDATE_NONE,
Chris@17 532 'fixture' => 'sec.8.x-1.2_8.x-2.2',
Chris@17 533 ],
Chris@17 534 // Security release available for module major release 1.
Chris@17 535 // Security release also available for next major.
Chris@17 536 '8.x-1.0, 8.x-1.2 8.x-2.2' => [
Chris@17 537 'module_patch_version' => '8.x-1.0',
Chris@17 538 'expected_security_releases' => ['8.x-1.2'],
Chris@17 539 'expected_update_message_type' => static::SECURITY_UPDATE_REQUIRED,
Chris@17 540 'fixture' => 'sec.8.x-1.2_8.x-2.2',
Chris@17 541 ],
Chris@17 542 // No security release available for module major release 1 but 1.x
Chris@17 543 // releases are not marked as insecure.
Chris@17 544 // Security release available for next major.
Chris@17 545 '8.x-1.0, 8.x-2.2, not insecure' => [
Chris@17 546 'module_patch_version' => '8.x-1.0',
Chris@17 547 'expected_security_releases' => [],
Chris@17 548 'expected_update_message_type' => static::UPDATE_AVAILABLE,
Chris@17 549 'fixture' => 'sec.8.x-2.2_1.x_secure',
Chris@17 550 ],
Chris@17 551 // On latest security release for module major release 1.
Chris@17 552 // Security release also available for next major.
Chris@17 553 '8.x-1.2, 8.x-1.2 8.x-2.2' => [
Chris@17 554 'module_patch_version' => '8.x-1.2',
Chris@17 555 'expected_security_release' => [],
Chris@17 556 'expected_update_message_type' => static::UPDATE_NONE,
Chris@17 557 'fixture' => 'sec.8.x-1.2_8.x-2.2',
Chris@17 558 ],
Chris@17 559 // @todo In https://www.drupal.org/node/2865920 add test cases:
Chris@17 560 // - 8.x-2.0 using fixture 'sec.8.x-1.2_8.x-2.2' to ensure that 8.x-2.2
Chris@17 561 // is the only security update.
Chris@17 562 // - 8.x-3.0-beta1 using fixture 'sec.8.x-1.2_8.x-2.2' to ensure that
Chris@17 563 // 8.x-2.2 is the only security update.
Chris@17 564 ];
Chris@17 565 }
Chris@17 566
Chris@0 567 }