diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-30 13:09:30 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-30 13:09:30 +0000 |
commit | a8f8a26f6d77f6aca8821e28e66ea253687d7d59 (patch) | |
tree | d0f2b694e18a3ccc343d379b3742791becb57b39 /modules/simpletest/tests/menu.test | |
parent | 15343a993ce45ec6626c79406aaa85c2631d023e (diff) | |
download | brdo-a8f8a26f6d77f6aca8821e28e66ea253687d7d59.tar.gz brdo-a8f8a26f6d77f6aca8821e28e66ea253687d7d59.tar.bz2 |
- Patch #553944 by David_Rothstein, ksenzee | JacobSingh, sun, jhodgdon, pwolanin: allow modules to specify per-page custom themes in hook_menu().
Diffstat (limited to 'modules/simpletest/tests/menu.test')
-rw-r--r-- | modules/simpletest/tests/menu.test | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index 26443f74e..d8ac5a882 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -18,6 +18,10 @@ class MenuIncTestCase extends DrupalWebTestCase { function setUp() { // Enable dummy module that implements hook_menu. parent::setUp('menu_test'); + // Make the tests below more robust by explicitly setting the default theme + // and administrative theme that they expect. + variable_set('theme_default', 'garland'); + variable_set('admin_theme', 'seven'); } /** @@ -30,6 +34,80 @@ class MenuIncTestCase extends DrupalWebTestCase { } /** + * Test the theme callback when it is set to use an administrative theme. + */ + function testThemeCallbackAdministrative() { + $this->drupalGet('menu-test/theme-callback/use-admin-theme'); + $this->assertText('Requested theme: seven. Actual theme: seven.', t('The administrative theme can be correctly set in a theme callback.')); + $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); + } + + /** + * Test that the theme callback is properly inherited. + */ + function testThemeCallbackInheritance() { + $this->drupalGet('menu-test/theme-callback/use-admin-theme/inheritance'); + $this->assertText('Requested theme: seven. Actual theme: seven. Theme callback inheritance is being tested.', t('Theme callback inheritance correctly uses the administrative theme.')); + $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); + } + + /** + * Test the theme callback when the site is in maintenance mode. + */ + function testThemeCallbackMaintenanceMode() { + variable_set('maintenance_mode', TRUE); + + // For a regular user, the fact that the site is in maintenance mode means + // we expect the theme callback system to be bypassed entirely. + $this->drupalGet('menu-test/theme-callback/use-admin-theme'); + $this->assertRaw('minnelli/minnelli.css', t("The maintenance theme's CSS appears on the page.")); + + // An administrator, however, should continue to see the requested theme. + $admin_user = $this->drupalCreateUser(array('access site in maintenance mode')); + $this->drupalLogin($admin_user); + $this->drupalGet('menu-test/theme-callback/use-admin-theme'); + $this->assertText('Requested theme: seven. Actual theme: seven.', t('The theme callback system is correctly triggered for an administrator when the site is in maintenance mode.')); + $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); + } + + /** + * Test the theme callback when it is set to use an optional theme. + */ + function testThemeCallbackOptionalTheme() { + // Request a theme that is not enabled. + $this->drupalGet('menu-test/theme-callback/use-stark-theme'); + $this->assertText('Requested theme: stark. Actual theme: garland.', t('The theme callback system falls back on the default theme when a theme that is not enabled is requested.')); + $this->assertRaw('garland/style.css', t("The default theme's CSS appears on the page.")); + + // Now enable the theme and request it again. + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($admin_user); + $this->drupalPost('admin/appearance', array('status[stark]' => 1), t('Save configuration')); + $this->drupalLogout(); + $this->drupalGet('menu-test/theme-callback/use-stark-theme'); + $this->assertText('Requested theme: stark. Actual theme: stark.', t('The theme callback system uses an optional theme once it has been enabled.')); + $this->assertRaw('stark/layout.css', t("The optional theme's CSS appears on the page.")); + } + + /** + * Test the theme callback when it is set to use a theme that does not exist. + */ + function testThemeCallbackFakeTheme() { + $this->drupalGet('menu-test/theme-callback/use-fake-theme'); + $this->assertText('Requested theme: fake_theme. Actual theme: garland.', t('The theme callback system falls back on the default theme when a theme that does not exist is requested.')); + $this->assertRaw('garland/style.css', t("The default theme's CSS appears on the page.")); + } + + /** + * Test the theme callback when no theme is requested. + */ + function testThemeCallbackNoThemeRequested() { + $this->drupalGet('menu-test/theme-callback/no-theme-requested'); + $this->assertText('Requested theme: NONE. Actual theme: garland.', t('The theme callback system falls back on the default theme when no theme is requested.')); + $this->assertRaw('garland/style.css', t("The default theme's CSS appears on the page.")); + } + + /** * Tests for menu_link_maintain(). */ function testMenuLinkMaintain() { |