Commit e20bcfbb authored by Dave Reid's avatar Dave Reid

by Dave Reid: Fix testing failures when running SimpleTests.

parent df6749e1
......@@ -9,6 +9,8 @@
*/
function xmlsitemap_sitemap_list_form() {
$destination = drupal_get_destination();
// Build the 'Update options' form.
$form['#operations'] = module_invoke_all('xmlsitemap_sitemap_operations');
$operations = array();
......@@ -56,7 +58,6 @@ function xmlsitemap_sitemap_list_form() {
$sitemaps = xmlsitemap_sitemap_load_multiple($smids);
$options = array();
$destination = drupal_get_destination();
foreach ($sitemaps as $smid => $sitemap) {
$sitemap['url'] = url($sitemap['uri']['path'], $sitemap['uri']['options']);
......
......@@ -281,27 +281,31 @@ function xmlsitemap_install() {
->condition('name', 'xmlsitemap')
->execute();
// Load the module and clear the schema cache.
// Load the module.
drupal_load('module', 'xmlsitemap');
drupal_get_schema(NULL, TRUE);
// Insert the homepage link into the {xmlsitemap} table so we do not show an
// empty sitemap after install.
// @todo Use xmlsitemap_save_link()?
db_insert('xmlsitemap')
->fields(array(
'type' => 'frontpage',
'id' => 0,
'loc' => '',
'priority' => variable_get('xmlsitemap_frontpage_priority', 1.0),
'changefreq' => XMLSITEMAP_FREQUENCY_DAILY,
'changefreq' => variable_get('xmlsitemap_frontpage_changefreq', XMLSITEMAP_FREQUENCY_DAILY),
'language' => LANGUAGE_NONE,
))
->execute();
// Insert the default context sitemap.
$sitemap = array('context' => array());
xmlsitemap_sitemap_save($sitemap);
$context = serialize(array());
db_insert('xmlsitemap_sitemap')
->fields(array(
'context' => $context,
'context_hash' => md5($context),
//'queued' => REQUEST_TIME,
))
->execute();
// @todo Does the sitemap show up on first install or is it a 404 page?
}
......@@ -310,8 +314,7 @@ function xmlsitemap_install() {
* Implements hook_enable().
*/
function xmlsitemap_enable() {
// Load the module and ensure the file cache directory is available and ready.
drupal_load('module', 'xmlsitemap');
// Ensure the file cache directory is available and ready.
xmlsitemap_check_directory();
variable_set('xmlsitemap_regenerate_needed', TRUE);
......
......@@ -1165,9 +1165,19 @@ function xmlsitemap_context_check(array $context) {
* Run a progressive batch operation.
*/
function xmlsitemap_run_progressive_batch() {
$batch = batch_get();
if (!empty($batch)) {
// If there is already something in the batch, don't run.
return FALSE;
}
$args = func_get_args();
$batch_callback = array_shift($args);
if (!lock_acquire($batch_callback)) {
return FALSE;
}
// Build the batch array.
$batch = call_user_func_array($batch_callback, $args);
batch_set($batch);
......@@ -1179,4 +1189,7 @@ function xmlsitemap_run_progressive_batch() {
// Run the batch process.
batch_process();
lock_release($batch_callback);
return TRUE;
}
......@@ -18,8 +18,8 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
function setUp() {
// Call parent::setUp() allowing test cases to pass further modules.
$modules = func_get_args();
$modules = array_merge(array('xmlsitemap'), $modules);
call_user_func_array(array('parent', 'setUp'), $modules);
$modules[] = 'xmlsitemap';
call_user_func_array(array($this, 'parent::setUp'), $modules);
// Ensure the files directory is created and writable during testing.
// @todo This can be removed when http://drupal.org/node/654752 is fixed.
......
......@@ -19,7 +19,7 @@ class XMLSitemapI18nWebTestCase extends XMLSitemapTestHelper {
// Call parent::setUp() allowing test cases to pass further modules.
$modules = func_get_args();
$modules = array_merge(array('locale', 'translation', 'i18n', 'xmlsitemap_i18n'), $modules);
call_user_func_array(array('parent', 'setUp'), $modules);
call_user_func_array(array($this, 'parent::setUp'), $modules);
// Add predefined language and reset the locale cache.
require_once DRUPAL_ROOT . '/includes/locale.inc';
......
......@@ -231,8 +231,8 @@ function xmlsitemap_node_create_link(stdClass &$node) {
$node->xmlsitemap['changecount'] = $node->nid ? count($timestamps) - 1 : 0;
// Node access must be reset since it a user may have changed published status, etc.
$access = &drupal_static('node_access');
unset($access[0][$node->nid]);
//$access = &drupal_static('node_access');
//unset($access[0][$node->nid]);
//node_access_acquire_grants($node);
// The following values must always be checked because they are volatile.
......@@ -256,8 +256,6 @@ function xmlsitemap_node_create_link(stdClass &$node) {
* TRUE if the operation may be performed, FALSE otherwise.
*
* This is for all intesive purposes a copy of Drupal 7's node_access() function.
* It invokes a backport of Drupal 7's hook_node_grants_alter() specifically
* for use with XML sitemap.
*/
function xmlsitemap_node_view_access($node, $account = NULL) {
global $user;
......
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