Commit 15de7560 authored by Dave Reid's avatar Dave Reid

by Dave Reid: Fixed test failures with status report messages.

parent 11a9dd8d
......@@ -98,17 +98,24 @@ function xmlsitemap_requirements($phase) {
* TRUE if there is a warning or error requirement, or FALSE otherwise.
*/
function xmlsitemap_check_status() {
$severity = REQUIREMENT_OK;
foreach (module_implements('requirements') as $module) {
if (strpos($module, 'xmlsitemap') !== FALSE) {
module_load_install($module);
$requirements = module_invoke($module, 'requirements', 'runtime');
$severity = max($severity, drupal_requirements_severity($requirements));
$messages = &drupal_static(__FUNCTION__);
if (!isset($messages)) {
$messages = array();
foreach (module_implements('requirements') as $module) {
if (strpos($module, 'xmlsitemap') !== FALSE) {
module_load_install($module);
$requirements = module_invoke($module, 'requirements', 'runtime');
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && max(REQUIREMENT_OK, $requirement['severity'])) {
$messages[] = $requirement['description'];
}
}
}
}
}
return $severity == REQUIREMENT_ERROR;
return $messages;
}
/**
......
......@@ -54,8 +54,8 @@ function xmlsitemap_help($path, $arg) {
if (!$checked && arg(0) == 'admin' && strpos($path, 'xmlsitemap') !== FALSE) {
$checked = TRUE;
module_load_install('xmlsitemap');
if (xmlsitemap_check_status() && user_access('administer site configuration')) {
drupal_set_message(t('One or more problems were detected with your XML sitemap configuration. Please check the <a href="@status-report">status report</a> for more information.', array('@status-report' => url('admin/reports/status'))), 'error', FALSE);
if (user_access('administer site configuration') && $messages = xmlsitemap_check_status()) {
drupal_set_message(t('One or more problems were detected with your XML sitemap configuration. Check the <a href="@status-report">status report</a> for more information.<br />!list', array('@status-report' => url('admin/reports/status'), '!list' => theme('item_list', array('items' => $messages)))), 'warning', FALSE);
}
module_load_include('inc', 'xmlsitemap');
if ($blurb = _xmlsitemap_get_blurb()) {
......
......@@ -149,16 +149,15 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
protected function assertXMLSitemapProblems($problem_text = FALSE) {
$this->drupalGet('admin/config/search/xmlsitemap');
$this->assertText(t('One or more problems were detected with your XML sitemap configuration. Please check the status report for more information.'));
$this->assertText(t('One or more problems were detected with your XML sitemap configuration. Check the status report for more information.'));
if ($problem_text) {
$this->clickLink(t('status report'));
$this->assertText($problem_text);
}
}
protected function assertNoXMLSitemapProblems() {
$this->drupalGet('admin/config/search/xmlsitemap');
$this->assertNoText(t('One or more problems were detected with your XML sitemap configuration. Please check the status report for more information.'));
$this->assertNoText(t('One or more problems were detected with your XML sitemap configuration. Check the status report for more information.'));
}
private function getWatchdogMessage(array $conditions) {
......@@ -662,6 +661,7 @@ class XMLSitemapFunctionalTest extends XMLSitemapTestHelper {
*/
function testStatusReport() {
// Test the rebuild flag.
variable_set('xmlsitemap_generated_last', REQUEST_TIME);
variable_set('xmlsitemap_rebuild_needed', TRUE);
$this->assertXMLSitemapProblems(t('The XML sitemap data is out of sync and needs to be completely rebuilt.'));
$this->clickLink(t('completely rebuilt'));
......@@ -671,7 +671,7 @@ class XMLSitemapFunctionalTest extends XMLSitemapTestHelper {
// Test the regenerate flag (and cron hasn't run in a while).
variable_set('xmlsitemap_regenerate_needed', TRUE);
variable_set('xmlsitemap_generated_last', REQUEST_TIME - variable_get('cron_threshold_warning', 172800) - 10);
variable_set('xmlsitemap_generated_last', REQUEST_TIME - variable_get('cron_threshold_warning', 172800) - 100);
$this->assertXMLSitemapProblems(t('The XML cached files are out of date and need to be regenerated. You can run cron manually to regenerate the sitemap files.'));
$this->clickLink(t('run cron manually'));
$this->assertResponse(200);
......
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