From ff88ee0f565ed9d3ebc0bba662987b0f0aacf9dc Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 21 Nov 2009 14:35:05 +0000 Subject: - Patch #601584 by effulgentsia, boombatower, yched: setUp() function for unit and web test cases should reset all resettable statics. --- modules/simpletest/tests/common.test | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'modules/simpletest/tests/common.test') diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index aa43a62eb..76c4d4dfc 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -56,8 +56,11 @@ class DrupalAlterTestCase extends DrupalWebTestCase { /** * Tests for URL generation functions. + * + * url() calls module_implements(), which may issue a db query, which requires + * inheriting from a web test case rather than a unit test case. */ -class CommonURLUnitTest extends DrupalUnitTestCase { +class CommonURLUnitTest extends DrupalWebTestCase { public static function getInfo() { return array( 'name' => 'URL generation tests', @@ -70,23 +73,9 @@ class CommonURLUnitTest extends DrupalUnitTestCase { * Confirm that invalid text given as $path is filtered. */ function testLXSS() { - global $conf; $text = $this->randomName(); $path = ""; - // Regardless of whether there is a theme override of theme_link() or not, - // unless the 'theme_link' configuration variable is FALSE, l() will - // attempt to initialize the theme system in order to determine if - // the link needs to be themed. However, drupal_theme_initialize() requires - // a database query, which doesn't work in the context of unit tests, - // because simpletest sets up a table prefix, but doesn't generate the - // corresponding prefixed tables. We need to either circumvent theme system - // initialization, or make CommonURLUnitTest inherit from DrupalWebTestCase. - // Since our goal in this unit test is specifically to test the default - // implementation, we choose the former. - $theme_link_saved = isset($conf['theme_link']) ? $conf['theme_link'] : NULL; - $conf['theme_link'] = FALSE; $link = l($text, $path); - $conf['theme_link'] = $theme_link_saved; $sanitized_path = check_url(url($path)); $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, t('XSS attack @path was filtered', array('@path' => $path))); } -- cgit v1.2.3