本文整理汇总了PHP中Captcha::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Captcha::setValue方法的具体用法?PHP Captcha::setValue怎么用?PHP Captcha::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Captcha
的用法示例。
在下文中一共展示了Captcha::setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Captcha
/**
* Creates and returns a captcha object from a row
* @param $row array
* @return Captcha object
*/
function &_returnCaptchaFromRow($row)
{
$captcha = new Captcha();
$captcha->setId($row['captcha_id']);
$captcha->setSessionId($row['session_id']);
$captcha->setValue($row['value']);
$captcha->setDateCreated($this->datetimeFromDB($row['date_created']));
HookRegistry::call('CaptchaDAO::_returnCaptchaFromRow', array(&$captcha, &$row));
return $captcha;
}
示例2: Captcha
/**
* Create a CAPTCHA object.
* @param $length int The length, in characters, of the CAPTCHA test to create
* @return object Captcha
*/
function &createCaptcha($length = 6)
{
$captchaDao =& DAORegistry::getDAO('CaptchaDAO');
$session =& Request::getSession();
if ($session && $this->isEnabled()) {
$captcha = new Captcha();
$captcha->setSessionId($session->getId());
$captcha->setValue(Validation::generatePassword($length));
$captchaDao->insertCaptcha($captcha);
} else {
$captcha = null;
}
return $captcha;
}
示例3: testIsValid
/**
* @covers FormValidatorCaptcha
* @covers FormValidator
*/
public function testIsValid()
{
// Test form
$form = new Form('some template');
$form->setData('testCaptchaId', 'test captcha id');
// Create a test Captcha
import('lib.pkp.classes.captcha.Captcha');
$captcha = new Captcha();
$captcha->setValue('expected captcha value');
$this->registerMockCaptchaDAO($captcha);
// Instantiate validator
$validator = new FormValidatorCaptcha($form, 'testData', 'testCaptchaId', 'some.message.key');
// Test valid captcha
$form->setData('testData', 'expected captcha value');
self::assertTrue($validator->isValid());
// Simulate invalid captcha value
$form->setData('testData', 'unexpected captcha value');
self::assertFalse($validator->isValid());
// Simulate invalid captcha id
$this->registerMockCaptchaDAO(null);
$form->setData('testData', 'expected captcha value');
self::assertFalse($validator->isValid());
}