public function TFATestCase::testAuthentication in Two-factor Authentication (TFA) 7
Same name and namespace in other branches
- 7.2 tests/tfa.test \TfaTestCase::testAuthentication()
File
- ./
tfa.test, line 81
Class
- TFATestCase
- Tests the functionality of the TFA module.
Code
public function testAuthentication() {
$account = $this
->drupalCreateUser(array());
$edit = array(
'name' => $account->name,
'pass' => $account->pass_raw,
);
$this
->drupalPost('user', $edit, t('Log in'));
// Check that TFA process has begun.
$this
->assertText($this
->interfaceStrings('sent'), 'The "TFA sent message" text appears');
$url_parts = explode('/', $this->url);
$login_hash = array_pop($url_parts);
// Get the login code.
$code = tfa_get_code($account->uid);
$edit = array(
'code' => $code['code'],
);
$this
->drupalPost('system/tfa/' . $account->uid . '/' . $login_hash, $edit, t('Log in'));
$this
->drupalGet('user');
$this
->assertLink('Log out', 0, 'The user succesfully logged in');
}