summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-11-27 20:25:44 +0000
committerDries Buytaert <dries@buytaert.net>2010-11-27 20:25:44 +0000
commit84c72d06f03163115ae9bbc939e6ab2dbc65eb28 (patch)
tree70506c548713a51c9f9e51e866849b5858de46fd /modules/simpletest
parent22cfc5bb2cf84d88356b50ab8f497add152d1858 (diff)
downloadbrdo-84c72d06f03163115ae9bbc939e6ab2dbc65eb28.tar.gz
brdo-84c72d06f03163115ae9bbc939e6ab2dbc65eb28.tar.bz2
- Patch #669510 by quicksketch, David_Rothstein, Dave Reid, casey, Gábor Hojtsy, mrfelton, effulgentsia: merge administration theme with hook_admin_paths().
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/batch.test6
-rw-r--r--modules/simpletest/tests/menu.test44
-rw-r--r--modules/simpletest/tests/menu_test.module5
3 files changed, 43 insertions, 12 deletions
diff --git a/modules/simpletest/tests/batch.test b/modules/simpletest/tests/batch.test
index e4aab37f2..b7bfc9bfb 100644
--- a/modules/simpletest/tests/batch.test
+++ b/modules/simpletest/tests/batch.test
@@ -299,12 +299,16 @@ class BatchPageTestCase extends DrupalWebTestCase {
// is using a different theme than would normally be used by the batch API.
variable_set('theme_default', 'bartik');
variable_set('admin_theme', 'seven');
+ // Log in as an administrator who can see the administrative theme.
+ $admin_user = $this->drupalCreateUser(array('view the administration theme'));
+ $this->drupalLogin($admin_user);
// 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/batch-test/test-theme');
- // The stack should contain the name of the the used on the progress page.
+ // The stack should contain the name of the theme used on the progress
+ // page.
$this->assertEqual(batch_test_stack(), array('seven'), t('A progressive batch correctly uses the theme of the page that started the batch.'));
}
}
diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test
index 7a4560408..f46b81df4 100644
--- a/modules/simpletest/tests/menu.test
+++ b/modules/simpletest/tests/menu.test
@@ -159,26 +159,35 @@ class MenuRouterTestCase extends DrupalWebTestCase {
}
/**
- * Test that the result of hook_custom_theme() overrides the theme callback.
+ * Test that hook_custom_theme() can control the theme of a page.
*/
function testHookCustomTheme() {
// Trigger hook_custom_theme() to dynamically request the Stark theme for
// the requested page.
variable_set('menu_test_hook_custom_theme_name', 'stark');
+ theme_enable(array('stark'));
- // Request a page whose theme callback returns the Seven theme. Since Stark
- // is not a currently enabled theme, our above request should be ignored,
- // and Seven should still be used.
- $this->drupalGet('menu-test/theme-callback/use-admin-theme');
- $this->assertText('Custom theme: seven. Actual theme: seven.', t('The result of hook_custom_theme() does not override a theme callback when it returns a theme that is not enabled.'));
- $this->assertRaw('seven/style.css', t("The Seven theme's CSS appears on the page."));
+ // Visit a page that does not implement a theme callback. The above request
+ // should be honored.
+ $this->drupalGet('menu-test/no-theme-callback');
+ $this->assertText('Custom theme: stark. Actual theme: stark.', t('The result of hook_custom_theme() is used as the theme for the current page.'));
+ $this->assertRaw('stark/layout.css', t("The Stark theme's CSS appears on the page."));
+ }
- // Now enable the Stark theme and request the same page as above. This
- // time, we expect hook_custom_theme() to prevail.
+ /**
+ * Test that the theme callback wins out over hook_custom_theme().
+ */
+ function testThemeCallbackHookCustomTheme() {
+ // Trigger hook_custom_theme() to dynamically request the Stark theme for
+ // the requested page.
+ variable_set('menu_test_hook_custom_theme_name', 'stark');
theme_enable(array('stark'));
+
+ // The menu "theme callback" should take precedence over a value set in
+ // hook_custom_theme().
$this->drupalGet('menu-test/theme-callback/use-admin-theme');
- $this->assertText('Custom theme: stark. Actual theme: stark.', t('The result of hook_custom_theme() overrides what was set in a theme callback.'));
- $this->assertRaw('stark/layout.css', t("The Stark theme's CSS appears on the page."));
+ $this->assertText('Custom theme: seven. Actual theme: seven.', t('The result of hook_custom_theme() does not override what was set in a theme callback.'));
+ $this->assertRaw('seven/style.css', t("The Seven theme's CSS appears on the page."));
}
/**
@@ -811,6 +820,19 @@ class MenuBreadcrumbTestCase extends DrupalWebTestCase {
$perms = array_keys(module_invoke_all('permission'));
$this->admin_user = $this->drupalCreateUser($perms);
$this->drupalLogin($this->admin_user);
+
+ // This test puts menu links in the Navigation menu and then tests for
+ // their presence on the page, so we need to ensure that the Navigation
+ // block will be displayed in all active themes.
+ db_update('block')
+ ->fields(array(
+ // Use a region that is valid for all themes.
+ 'region' => 'content',
+ 'status' => 1,
+ ))
+ ->condition('module', 'system')
+ ->condition('delta', 'navigation')
+ ->execute();
}
/**
diff --git a/modules/simpletest/tests/menu_test.module b/modules/simpletest/tests/menu_test.module
index b3577dbdc..4d673e8af 100644
--- a/modules/simpletest/tests/menu_test.module
+++ b/modules/simpletest/tests/menu_test.module
@@ -58,6 +58,11 @@ function menu_test_menu() {
'page arguments' => array(TRUE),
'access arguments' => array('access content'),
);
+ $items['menu-test/no-theme-callback'] = array(
+ 'title' => 'Page that displays different themes without using a theme callback.',
+ 'page callback' => 'menu_test_theme_page_callback',
+ 'access arguments' => array('access content'),
+ );
// Path containing "exotic" characters.
$path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.