public function testBuildHash()
 {
     $data = array('captcha_time' => time(), 'captcha' => '2');
     $options = array('salt' => 'xyz', 'checkIp' => true, 'checkSession' => true);
     $res = CaptchaLib::buildHash($data, $options);
     pr($res);
     $this->assertTrue(strlen($res) == 40);
 }
 public function testCorrect()
 {
     App::uses('CaptchaLib', 'Tools.Lib');
     $Captcha = new CaptchaLib();
     $hash = $Captcha->buildHash(['captcha' => 2, 'captcha_time' => time() - 10, ''], CaptchaLib::$defaults);
     $data = ['title' => 'xyz', 'captcha' => '2', 'homepage' => '', 'captcha_hash' => $hash, 'captcha_time' => time() - 10];
     $this->Comment->set($data);
     $is = $this->Comment->validates();
     //debug($this->Comment->invalidFields());
     $this->assertTrue($is);
 }
Beispiel #3
0
 /**
  * @param array $captchaCode
  */
 protected function buildHash($data)
 {
     return CaptchaLib::buildHash($data, $this->settings, true);
 }
Beispiel #4
0
 /**
  * CaptchaBehavior::_buildHash()
  *
  * @param array $data
  * @return string Hash
  */
 protected function _buildHash($data)
 {
     return CaptchaLib::buildHash($data, $this->settings[$this->Model->alias]);
 }