You are here

protected function BotchaBaseWebTestCase::assertUserLoginFormSubmission in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.2 botcha.test \BotchaBaseWebTestCase::assertUserLoginFormSubmission()
  2. 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::assertUserLoginFormSubmission()
  3. 7.2 botcha.test \BotchaBaseWebTestCase::assertUserLoginFormSubmission()

Assert submission of user login form, check whether it works how it should.

Parameters

type $edit:

type $should_pass:

1 call to BotchaBaseWebTestCase::assertUserLoginFormSubmission()
BotchaBaseWebTestCase::assertFormSubmission in tests/botcha.simpletest.test
Check whether our suspections are real.

File

tests/botcha.simpletest.test, line 673
Simpletest-tests for BOTCHA module.

Class

BotchaBaseWebTestCase
Base class for BOTCHA tests.

Code

protected function assertUserLoginFormSubmission($edit, $should_pass, $button) {
  switch ($should_pass) {
    case FALSE:

      // Check for error message.
      $this
        ->assertText(BOTCHA_WRONG_RESPONSE_ERROR_MESSAGE, 'BOTCHA should block user login form', 'BOTCHA');

      // And make sure that user is not logged in:
      // check for name and password fields on ?q=user.
      $this
        ->drupalGet('user');
      $this
        ->assertField('name', t('Username field found.'), 'BOTCHA');
      $this
        ->assertField('pass', t('Password field found.'), 'BOTCHA');
      break;
    case TRUE:
    default:

      // If log in was successful, log out to continue testing.
      $this
        ->drupalLogout();
      break;
  }
}