summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-12-18 00:42:55 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-12-18 00:42:55 +0000
commita7d66871bd3f9c4709e2e30ad16efc8199ad3455 (patch)
tree942acbb085f98f3ec6623849dd51de2405bdbf10 /modules
parent574a2e47eea1bc8e2ea13240e407a32e4b728560 (diff)
downloadbrdo-a7d66871bd3f9c4709e2e30ad16efc8199ad3455.tar.gz
brdo-a7d66871bd3f9c4709e2e30ad16efc8199ad3455.tar.bz2
#283246 by Damien Tournoud, Dave Reid, drewish, boombatower: Store original user when prior to running tests.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/drupal_web_test_case.php20
-rw-r--r--modules/simpletest/tests/session.test2
2 files changed, 19 insertions, 3 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 43795c988..60382b6bf 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -92,6 +92,13 @@ class DrupalWebTestCase {
protected $originalFileDirectory = NULL;
/**
+ * The original user, before it was changed to a clean uid = 1 for testing purposes.
+ *
+ * @var object
+ */
+ protected $originalUser = NULL;
+
+ /**
* Current results of this test case.
*
* @var Array
@@ -779,7 +786,7 @@ class DrupalWebTestCase {
* List of modules to enable for the duration of the test.
*/
protected function setUp() {
- global $db_prefix;
+ global $db_prefix, $user;
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
@@ -814,6 +821,11 @@ class DrupalWebTestCase {
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
+ // Log in with a clean $user.
+ $this->originalUser = $user;
+ drupal_save_session(FALSE);
+ $user = user_load(array('uid' => 1));
+
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
@@ -860,7 +872,7 @@ class DrupalWebTestCase {
* and reset the database prefix.
*/
protected function tearDown() {
- global $db_prefix;
+ global $db_prefix, $user;
if (preg_match('/simpletest\d+/', $db_prefix)) {
// Delete temporary files directory and reset files directory path.
simpletest_clean_temporary_directory(file_directory_path());
@@ -876,6 +888,10 @@ class DrupalWebTestCase {
// Return the database prefix to the original.
$db_prefix = $this->originalPrefix;
+ // Return the user to the original one.
+ $user = $this->originalUser;
+ drupal_save_session(TRUE);
+
// Ensure that the internal logged in variable is reset.
$this->isLoggedIn = FALSE;
diff --git a/modules/simpletest/tests/session.test b/modules/simpletest/tests/session.test
index 85a1bb80d..ec27378e3 100644
--- a/modules/simpletest/tests/session.test
+++ b/modules/simpletest/tests/session.test
@@ -23,7 +23,7 @@ class SessionTestCase extends DrupalWebTestCase {
* Tests for drupal_save_session() and drupal_session_regenerate().
*/
function testSessionSaveRegenerate() {
- $this->assertTrue(drupal_save_session(), t('drupal_save_session() correctly returns TRUE when initially called with no arguments.'), t('Session'));
+ $this->assertFalse(drupal_save_session(), t('drupal_save_session() correctly returns FALSE (inside of testing framework) when initially called with no arguments.'), t('Session'));
$this->assertFalse(drupal_save_session(FALSE), t('drupal_save_session() correctly returns FALSE when called with FALSE.'), t('Session'));
$this->assertFalse(drupal_save_session(), t('drupal_save_session() correctly returns FALSE when saving has been disabled.'), t('Session'));
$this->assertTrue(drupal_save_session(TRUE), t('drupal_save_session() correctly returns TRUE when called with TRUE.'), t('Session'));