/** * Make sure that the request password form is protected correctly. */ function testUserPasswordCaptcha() { $this->drupalLogin($this->adminUser); // Verify that the protection mode defaults to CAPTCHA. $this->drupalGet('admin/config/content/mollom/add-form', ['query' => ['form_id' => 'user_pass']]); $this->assertFieldByName('mode', FormInterface::MOLLOM_MODE_CAPTCHA); $this->setProtectionUI('user_pass', FormInterface::MOLLOM_MODE_CAPTCHA); $this->drupalLogout(); // Create a new user. $this->webUser = $this->drupalCreateUser(array()); $this->drupalGet('user/password'); // Try to reset the user's password by specifying an invalid CAPTCHA. $edit = ['name' => $this->webUser->getAccountName()]; $this->postIncorrectCaptcha('user/password', $edit, t('Submit')); $this->postCorrectCaptcha(NULL, [], t('Submit')); // Try to reset the user's password by specifying a valid CAPTCHA. $this->postCorrectCaptcha('user/password', $edit, t('Submit')); $this->assertText(t('Further instructions have been sent to your email address.')); }