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

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

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