本文整理汇总了PHP中UnitTestCase::pdo方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitTestCase::pdo方法的具体用法?PHP UnitTestCase::pdo怎么用?PHP UnitTestCase::pdo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitTestCase
的用法示例。
在下文中一共展示了UnitTestCase::pdo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCheckCaptcha
/**
* @depends testMakeCaptcha
*/
public function testCheckCaptcha()
{
$capTime = $_SERVER['REQUEST_TIME'];
$this->assertEquals(self::EXIST_MOBILE, $this->mdu->checkCaptcha('15280255990', 1, '1234', $capTime));
$this->assertEquals(self::EXIST_MOBILE, $this->mdu->checkCaptcha('15280255990', 11, '1234', $capTime));
$this->assertEquals(self::NON_EXIST_MOBILE, $this->mdu->checkCaptcha('15280255992', 3, '1234', $capTime));
$this->assertEquals(self::NON_EXIST_MOBILE, $this->mdu->checkCaptcha('15280255992', 7, '1234', $capTime));
$this->assertEquals(self::NON_EXIST_MOBILE, $this->mdu->checkCaptcha('15280255992', 9, '1234', $capTime));
parent::pdo()->exec('UPDATE cloud_mobi_captcha SET `mc_captcha` = "6789", `mc_validtime` = 10 WHERE `mc_mobi` = "15280255991"');
$this->assertEquals(self::ERROR_CAPTCHA, $this->mdu->checkCaptcha('15280255991', 1, '1234', $capTime));
$this->assertEquals(self::INVALID_CAPTCHA, $this->mdu->checkCaptcha('15280255991', 1, '6789', $capTime));
// 当前时间小于验证码添加时间
$mcAddtime = $capTime + 60;
parent::pdo()->exec('UPDATE cloud_mobi_captcha SET `mc_validtime` = 0, `mc_addtime` = ' . $mcAddtime . ' WHERE `mc_mobi` = "15280255991"');
$this->assertEquals(self::INVALID_CAPTCHA, $this->mdu->checkCaptcha('15280255991', 1, '6789', $capTime));
// 验证码过期
$mcAddtime = $capTime - $this->di['sysconfig']['capTime'] - 1000;
parent::pdo()->exec('UPDATE cloud_mobi_captcha SET `mc_validtime` = 0, `mc_addtime` = ' . $mcAddtime . ' WHERE `mc_mobi` = "15280255991"');
$this->assertEquals(self::INVALID_CAPTCHA, $this->mdu->checkCaptcha('15280255991', 1, '6789', $capTime));
// 验证码有效
$mcAddtime = $capTime - $this->di['sysconfig']['capTime'] + 1000;
parent::pdo()->exec('UPDATE cloud_mobi_captcha SET `mc_validtime` = 0, `mc_addtime` = ' . $mcAddtime . ' WHERE `mc_mobi` = "15280255991"');
$this->assertEquals(self::SUCCESS, $this->mdu->checkCaptcha('15280255991', 1, '6789', $capTime));
}