summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/batch.test34
-rw-r--r--modules/simpletest/tests/system_test.module33
2 files changed, 67 insertions, 0 deletions
diff --git a/modules/simpletest/tests/batch.test b/modules/simpletest/tests/batch.test
index a3ace7b9e..897e8a803 100644
--- a/modules/simpletest/tests/batch.test
+++ b/modules/simpletest/tests/batch.test
@@ -7,6 +7,40 @@
*/
/**
+ * Tests for the batch API progress page theme.
+ */
+class BatchAPIThemeTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Batch API progress page theme',
+ 'description' => 'Tests that while a progressive batch is running, it correctly uses the theme of the page that started the batch.',
+ 'group' => 'Batch API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('system_test');
+ // Make sure that the page which starts the batch (an administrative page)
+ // is using a different theme than would normally be used by the batch API.
+ variable_set('theme_default', 'garland');
+ variable_set('admin_theme', 'seven');
+ }
+
+ /**
+ * Tests that the batch API progress page uses the correct theme.
+ */
+ function testBatchAPIProgressPageTheme() {
+ // Visit an administrative page that runs a test batch, and check that the
+ // theme that was used during batch execution (which the batch callback
+ // function saved as a variable) matches the theme used on the
+ // administrative page.
+ $this->drupalGet('admin/system-test/batch-theme');
+ $batch_theme_used = variable_get('system_test_batch_theme_used', 'garland');
+ $this->assertEqual($batch_theme_used, 'seven', t('A progressive batch correctly uses the theme of the page that started the batch.'));
+ }
+}
+
+/**
* Tests the function _batch_api_percentage() to make sure that the rounding
* works properly in all cases.
*/
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index be4d443f5..670305536 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -5,6 +5,11 @@
* Implement hook_menu().
*/
function system_test_menu() {
+ $items['admin/system-test/batch-theme'] = array(
+ 'page callback' => 'system_test_batch_theme',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
$items['system-test/sleep/%'] = array(
'page callback' => 'system_test_sleep',
'page arguments' => array(2),
@@ -97,6 +102,34 @@ function system_test_menu() {
return $items;
}
+/**
+ * Menu callback; start a new batch for testing the batch progress page theme.
+ */
+function system_test_batch_theme() {
+ $batch = array(
+ 'operations' => array(
+ array('system_test_batch_theme_callback', array()),
+ ),
+ );
+ batch_set($batch);
+ // Force the batch to redirect to some page other than this one (to avoid an
+ // infinite loop).
+ batch_process('node');
+}
+
+/**
+ * Batch callback function for testing the theme used by a batch.
+ */
+function system_test_batch_theme_callback() {
+ // Because drupalGet() steps through the full progressive batch before
+ // returning control to the test function, we cannot test that the correct
+ // theme is being used on the batch processing page by viewing that page
+ // directly. Instead, we save the theme being used in a variable here, so
+ // that it can be loaded and inspected in the thread running the test.
+ global $theme;
+ variable_set('system_test_batch_theme_used', $theme);
+}
+
function system_test_sleep($seconds) {
sleep($seconds);
}