public function MobileNumberElementTestCase::testTfa in Mobile Number 7
Test tfa option.
File
- tests/
mobile_number.element.test, line 200
Class
- MobileNumberElementTestCase
- Class for testing mobile_number element.
Code
public function testTfa() {
$number = '0502345678';
$country = 'IL';
$value = '+972502345678';
$code = MobileNumber::generateVerificationCode();
$token = MobileNumber::registerVerificationCode($code, $value);
$element = array(
'#type' => 'mobile_number',
'#title' => 'M',
'#mobile_number' => array(
'tfa' => TRUE,
),
);
$input['tfa'] = 1;
$input['country-code'] = $country;
$input['mobile'] = $number;
$element['#default_value']['verified'] = 0;
$errors = $this
->submitFormElement($element, $input, $value);
$this
->assertTrue($errors, "Two factor authentication enabling failure.", 'TFA enabling');
$input['verification_token'] = $token;
$input['verification_code'] = $code;
$errors = $this
->submitFormElement($element, $input, $value);
$this
->assertTrue(!$errors, "Two factor authentication enabled successfully.", 'TFA enabling');
}