I want to test a module that adds an additional login validation clause. Only users whitelisted somewhere else are allowed to log in to the system.
In order to test this behaviour with Simpletest, I would like to assert that a random user has no access to the system.
I have tried to create this random user and then to call
drupalLogin(). Unfortunately, my test fails because
drupalLogin() is checking whether the log in succeeded, by calling
This is what I have tried:
$user = $this->drupalCreateUser(array()); $user->roles = 'authenticated user'; user_save($user); // Try to login with it // It fails, because of the additional validation performed by my custom module $this->drupalLogin($user); // I would like to assert it here instead: $this->assertFalse(isset($this->loggedInUser->uid));
What should I do in order to avoid the assertion to fail at
drupalLogin(), so that I can assert it myself?
Any help will be appreciated.