public function testVerifyCaptcha() { // Test verifyCaptcha throws an exception when passed bad data try { \Captcha\Factory\Module::verifyCaptchaClass('BadCaptchaClass'); $this->fail('verifyCaptchaClass should throw exception'); } catch (Exception $e) { } // Test verifyCaptcha does not throws an exception when passed good data try { \Captcha\Factory\Module::verifyCaptchaClass('\\Captcha\\Module\\ReCaptcha'); \Captcha\Factory\Module::verifyCaptchaClass('\\Captcha\\Module\\FancyCaptcha'); } catch (Exception $e) { $this->fail('verifyCaptchaClass should not throw exception'); } }
/** * Backend function for confirmEdit() and confirmEditAPI() * * @param \EditPage $editPage * @param string $newText * @param string $section * @param bool $merged * * @return bool false if the CAPTCHA is rejected, true otherwise */ private function doConfirmEdit($editPage, $newText, $section, $merged = false) { if ($this->wg->Request->getVal('captchaid')) { $this->wg->Request->setVal('wpCaptchaId', $this->wg->Request->getVal('captchaid')); } if ($this->wg->Request->getVal('captchaword')) { $this->wg->Request->setVal('wpCaptchaWord', $this->wg->Request->getVal('captchaword')); } if ($this->shouldCheck($editPage, $newText, $section, $merged)) { return Factory\Module::getInstance()->passCaptcha(); } else { $this->log("no need to show captcha.\n"); return true; } }