Browse Source

No longer auto login the admin user breaks other tests that expect the anon user to be logged in.

pull/346/head
Nigel Banks 12 years ago
parent
commit
054278bc85
  1. 4
      tests/README.md
  2. 3
      tests/ingest.test
  3. 26
      tests/islandora_web_test_case.inc

4
tests/README.txt → tests/README.md

@ -1,4 +1,4 @@
You can define your own configurations specific to your enviroment by copying 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 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 file. These test need write access to the system's $FEDORA_HOME/server/config
directory as well as the filter-drupal.xml file. directory as well as the filter-drupal.xml file.

3
tests/ingest.test

@ -71,7 +71,8 @@ class IslandoraIngestsTestCase extends IslandoraWebTestCase {
* Test Ingest Steps. * Test Ingest Steps.
*/ */
public function testIngest() { public function testIngest() {
global $user; // Login the Admin user.
$this->drupalLogin($this->admin);
// First step in form. // First step in form.
$this->drupalGet('test/ingest'); $this->drupalGet('test/ingest');
// Default model selected, has no additional steps. // Default model selected, has no additional steps.

26
tests/islandora_web_test_case.inc

@ -93,7 +93,6 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
$roles = user_roles(); $roles = user_roles();
$index = array_search('administrator', $roles); $index = array_search('administrator', $roles);
$user = $this->drupalCreateUser(); $user = $this->drupalCreateUser();
$this->drupalLogin($user);
$user->roles[$index] = 'administrator'; $user->roles[$index] = 'administrator';
$user->name = $this->configuration['admin_user']; $user->name = $this->configuration['admin_user'];
$user->pass = $this->configuration['admin_pass']; $user->pass = $this->configuration['admin_pass'];
@ -104,6 +103,31 @@ class IslandoraWebTestCase extends DrupalWebTestCase {
return $user; 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. * Stores the content of the Drupal Filter for later restoration.
*/ */

Loading…
Cancel
Save