You are here

public function TfaTestCase::testSendError in Two-factor Authentication (TFA) 7.2

Test that TFA correctly sets error messages.

Messages originate from plugins that error during the begin() process.

File

tests/tfa.test, line 188
Drupal test cases for TFA.

Class

TfaTestCase
Tests the functionality of the TFA module.

Code

public function testSendError() {

  // Enable test plugin.
  variable_set('tfa_validate_plugin', 'tfa_test_send');

  // Cause the send plugin to have a begin process error.
  variable_set('tfa_test_send_begin', FALSE);
  $account = $this->web_user;
  $edit = array(
    'name' => $account->name,
    'pass' => $account->pass_raw,
  );
  $this
    ->drupalPost('user/login', $edit, 'Log in');
  $this
    ->assertText('Error during send', 'Error message appears for begin error');

  // Test resend.
  $this
    ->drupalPost(NULL, array(), 'Resend');
  $this
    ->assertText('Error during resend', 'Error message appears for resend');
}