diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-05 02:26:36 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-05 02:26:36 +0000 |
commit | 03f9a31663c2aa8e1e62f7c8ee8d8eefbb1444db (patch) | |
tree | 29fef81aacceefb67786ec12a22d9746dd4baa9b /modules | |
parent | e061e0964d8a07acf04149f45e81f86d7bfb2c93 (diff) | |
download | brdo-03f9a31663c2aa8e1e62f7c8ee8d8eefbb1444db.tar.gz brdo-03f9a31663c2aa8e1e62f7c8ee8d8eefbb1444db.tar.bz2 |
#319033 by dww, Dave Reid, Ralf: Fixed weird order of projects listed on updates page (with tests).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/update/update.report.inc | 4 | ||||
-rw-r--r-- | modules/update/update.test | 74 |
2 files changed, 77 insertions, 1 deletions
diff --git a/modules/update/update.report.inc b/modules/update/update.report.inc index e5ed7c867..831b5d217 100644 --- a/modules/update/update.report.inc +++ b/modules/update/update.report.inc @@ -199,7 +199,8 @@ function theme_update_report($data) { if (!isset($rows[$project['project_type']])) { $rows[$project['project_type']] = array(); } - $rows[$project['project_type']][] = array( + $row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']); + $rows[$project['project_type']][$row_key] = array( 'class' => array($class), 'data' => array($row), ); @@ -214,6 +215,7 @@ function theme_update_report($data) { ); foreach ($project_types as $type_name => $type_label) { if (!empty($rows[$type_name])) { + ksort($rows[$type_name]); $output .= "\n<h3>" . $type_label . "</h3>\n"; $output .= theme('table', $header, $rows[$type_name], array('class' => array('update'))); } diff --git a/modules/update/update.test b/modules/update/update.test index 5a4b163c9..58e9b6982 100644 --- a/modules/update/update.test +++ b/modules/update/update.test @@ -192,5 +192,79 @@ class UpdateTestContribCase extends UpdateTestHelper { $this->assertNoText(t('Update available')); $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), t('Link to aaa_update_test project appears.')); } + + /** + * Test that contrib projects are ordered by project name. + * + * If a project contains multiple modules, we want to make sure that the + * available updates report is sorted by the parent project names, not by + * the names of the modules included in each project. In this test case, we + * have 2 contrib projects, "BBB Update test" and "CCC Update test". + * However, we have a module called "aaa_update_test" that's part of the + * "CCC Update test" project. We need to make sure that we see the "BBB" + * project before the "CCC" project, even though "CCC" includes a module + * that's processed first if you sort alphabetically by module name (which + * is the order we see things inside system_get_module_data() for example). + */ + function testUpdateContribOrder() { + // We want core to be version 7.0. + $system_info = array( + '#all' => array( + 'version' => '7.0', + ), + // All the rest should be visible as contrib modules at version 7.x-1.0. + + // aaa_update_test needs to be part of the "CCC Update test" project, + // which would throw off the report if we weren't properly sorting by + // the project names. + 'aaa_update_test' => array( + 'project' => 'ccc_update_test', + 'version' => '7.x-1.0', + 'hidden' => FALSE, + ), + + // This should be its own project, and listed first on the report. + 'bbb_update_test' => array( + 'project' => 'bbb_update_test', + 'version' => '7.x-1.0', + 'hidden' => FALSE, + ), + + // This will contain both aaa_update_test and ccc_update_test, and + // should come after the bbb_update_test project. + 'ccc_update_test' => array( + 'project' => 'ccc_update_test', + 'version' => '7.x-1.0', + 'hidden' => FALSE, + ), + ); + variable_set('update_test_system_info', $system_info); + $this->refreshUpdateStatus(array('drupal' => '0', '#all' => '1_0')); + $this->drupalGet('admin/reports/updates'); + $this->standardTests(); + // We're expecting the report to say all projects are up to date. + $this->assertText(t('Up to date')); + $this->assertNoText(t('Update available')); + // We want to see all 3 module names listed, since they'll show up either + // as project names or as modules under the "Includes" listing. + $this->assertText(t('AAA Update test')); + $this->assertText(t('BBB Update test')); + $this->assertText(t('CCC Update test')); + // We want aaa_update_test included in the ccc_update_test project, not as + // its own project on the report. + $this->assertNoRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), t('Link to aaa_update_test project does not appear.')); + // The other two should be listed as projects. + $this->assertRaw(l(t('BBB Update test'), 'http://example.com/project/bbb_update_test'), t('Link to bbb_update_test project appears.')); + $this->assertRaw(l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), t('Link to bbb_update_test project appears.')); + + // We want to make sure we see the BBB project before the CCC project. + // Instead of just searching for 'BBB Update test' or something, we want + // to use the full markup that starts the project entry itself, so that + // we're really testing that the project listings are in the right order. + $bbb_project_link = '<div class="project"><a href="http://example.com/project/bbb_update_test">BBB Update test</a>'; + $ccc_project_link = '<div class="project"><a href="http://example.com/project/ccc_update_test">CCC Update test</a>'; + $this->assertTrue(strpos($this->drupalGetContent(), $bbb_project_link) < strpos($this->drupalGetContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project"); + } + } |