Is it possible to log in as a specific user? I can't get the following to work:

function testSampleLogin() {
    // Log in using sample user credentials (user exists in Drupal instance)
    $edit = array('name' => 'testuser', 'pass' => 'testuserpass');
    // Try to log in at /user
    $this->drupalPost('user', $edit, t('Log in'));
    // If login successful, we'll see a 'Log out' link
    $this->assertRaw('<a href="'. url('logout') .'">', t('Make sure a link appears to "Log out"'));  }
}

My test gets to the /login page ("Valid HTML found on "http://localhost/drupal6/user") but fails at the above function. I'm testing an external authentication module, which I know works, since I can log in manually using the above credentials.

Comments

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

Do you configure the external login module during the test? SimpleTest creates a blank environment when running the test so any configuration settings that point to the external datasource will be lost.

Also note:

$this->drupalLogin($user);
markj’s picture

@boombatower, thanks a million. Adding

 function setUp() {
    // Enable ilsauthen, the module I am testing...
    parent::setUp('ilsauthen'); 
  }

before my test function works.

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Postponed (maintainer needs more info) » Fixed

Good to hear.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.