diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-01-30 20:24:49 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-01-30 20:24:49 -0800 |
commit | bbede7f65093c4f85a99dc94282809436effc799 (patch) | |
tree | b6819bd0f2defca621cea1927f1f9e2f4767ef28 /modules/simpletest/tests | |
parent | c367b7d954e04cd10008c0f6111cb36c67b0ba0c (diff) | |
download | brdo-bbede7f65093c4f85a99dc94282809436effc799.tar.gz brdo-bbede7f65093c4f85a99dc94282809436effc799.tar.bz2 |
Issue #1371484 by catch, langworthy, makara, ArtistConk: Fixed Private properties in abstract class DrupalCacheArray.
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r-- | modules/simpletest/tests/theme.test | 51 | ||||
-rw-r--r-- | modules/simpletest/tests/theme_test.module | 14 | ||||
-rw-r--r-- | modules/simpletest/tests/theme_test.template_test.tpl.php | 2 |
3 files changed, 67 insertions, 0 deletions
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index d54885099..af1141124 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -382,3 +382,54 @@ class ThemeHtmlTag extends DrupalUnitTestCase { $this->assertEqual('<title>title test</title>'."\n", theme_html_tag($tag), t('Test title tag generation.')); } } + +/** + * Tests for the ThemeRegistry class. + */ +class ThemeRegistryTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'ThemeRegistry', + 'description' => 'Tests the behavior of the ThemeRegistry class', + 'group' => 'Theme', + ); + } + function setUp() { + parent::setUp('theme_test'); + } + + /** + * Tests the behavior of the theme registry class. + */ + function testRaceCondition() { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $cid = 'test_theme_registry'; + + // Directly instantiate the theme registry, this will cause a base cache + // entry to be written in __construct(). + $registry = new ThemeRegistry($cid, 'cache'); + + $this->assertTrue(cache_get($cid), 'Cache entry was created.'); + + // Trigger a cache miss for an offset. + $this->assertTrue($registry['theme_test_template_test'], 'Offset was returned correctly from the theme registry.'); + // This will cause the ThemeRegistry class to write an updated version of + // the cache entry when it is destroyed, usually at the end of the request. + // Before that happens, manually delete the cache entry we created earlier + // so that the new entry is written from scratch. + cache_clear_all($cid, 'cache'); + + // Destroy the class so that it triggers a cache write for the offset. + unset($registry); + + $this->assertTrue(cache_get($cid), 'Cache entry was created.'); + + // Create a new instance of the class. Confirm that both the offset + // requested previously, and one that has not yet been requested are both + // available. + $registry = new ThemeRegistry($cid, 'cache'); + + $this->assertTrue($registry['theme_test_template_test'], 'Offset was returned correctly from the theme registry'); + $this->assertTrue($registry['theme_test_template_test_2'], 'Offset was returned correctly from the theme registry'); + } +} diff --git a/modules/simpletest/tests/theme_test.module b/modules/simpletest/tests/theme_test.module index 9cec5381d..48e2e83c6 100644 --- a/modules/simpletest/tests/theme_test.module +++ b/modules/simpletest/tests/theme_test.module @@ -1,6 +1,20 @@ <?php /** + * Implements hook_theme(). + */ +function theme_test_theme($existing, $type, $theme, $path) { + $items['theme_test_template_test'] = array( + 'template' => 'theme_test.template_test', + ); + $items['theme_test_template_test_2'] = array( + 'template' => 'theme_test.template_test', + ); + + return $items; +} + +/** * Implements hook_system_theme_info(). */ function theme_test_system_theme_info() { diff --git a/modules/simpletest/tests/theme_test.template_test.tpl.php b/modules/simpletest/tests/theme_test.template_test.tpl.php new file mode 100644 index 000000000..cde8faadd --- /dev/null +++ b/modules/simpletest/tests/theme_test.template_test.tpl.php @@ -0,0 +1,2 @@ +<!-- Output for Theme API test --> +Fail: Template not overridden. |