Commit 03f9a316 authored by webchick's avatar webchick

#319033 by dww, Dave Reid, Ralf: Fixed weird order of projects listed on updates page (with tests).

parent e061e096
......@@ -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')));
}
......
......@@ -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");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment