Closed (fixed)
Project:
SimpleTest
Version:
6.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
9 Mar 2009 at 04:15 UTC
Updated:
25 Mar 2009 at 03:20 UTC
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
Comment #1
boombatower commentedDo 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:
Comment #2
markj commented@boombatower, thanks a million. Adding
before my test function works.
Comment #3
boombatower commentedGood to hear.