diff --git a/tests/README.txt b/tests/README.md similarity index 54% rename from tests/README.txt rename to tests/README.md index c03004ae..c4a0ae1a 100644 --- a/tests/README.txt +++ b/tests/README.md @@ -1,4 +1,4 @@ You can define your own configurations specific to your enviroment by copying default.test_config.ini to test_config.ini, making your changes in the copied -file. These test need write access to the system's $FEDORA_HOME/server/config -directory as well as the filter-drupal.xml file. \ No newline at end of file +file. These test need write access to the system's $FEDORA_HOME/server/config +directory as well as the filter-drupal.xml file. diff --git a/tests/ingest.test b/tests/ingest.test index 0878076b..173b926f 100644 --- a/tests/ingest.test +++ b/tests/ingest.test @@ -71,7 +71,8 @@ class IslandoraIngestsTestCase extends IslandoraWebTestCase { * Test Ingest Steps. */ public function testIngest() { - global $user; + // Login the Admin user. + $this->drupalLogin($this->admin); // First step in form. $this->drupalGet('test/ingest'); // Default model selected, has no additional steps. diff --git a/tests/islandora_web_test_case.inc b/tests/islandora_web_test_case.inc index 2967280d..a39e9a45 100644 --- a/tests/islandora_web_test_case.inc +++ b/tests/islandora_web_test_case.inc @@ -93,7 +93,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase { $roles = user_roles(); $index = array_search('administrator', $roles); $user = $this->drupalCreateUser(); - $this->drupalLogin($user); $user->roles[$index] = 'administrator'; $user->name = $this->configuration['admin_user']; $user->pass = $this->configuration['admin_pass']; @@ -104,6 +103,31 @@ class IslandoraWebTestCase extends DrupalWebTestCase { return $user; } + /** + * Logs in the given user, handles the special case where the user is admin. + * + * @see DrupalWebTestCase::drupalLogin() + */ + protected function drupalLogin(stdClass &$account) { + if ($account->uid == $this->admin->uid) { + // Create password for Drupal. + $edit = array('pass' => user_password()); + $account = user_save($account, $edit); + // Raw password is used to login. + $account->pass_raw = $edit['pass']; + // We must login before changing the password for fedora. + parent::drupalLogin($account); + $account->name = $this->configuration['admin_user']; + $account->pass = $this->configuration['admin_pass']; + // Save the fedora admin credentials for later GET/POST requests. + $account = user_save($account); + } + else { + parent::drupalLogin($account); + } + } + + /** * Stores the content of the Drupal Filter for later restoration. */