/**
  * 调用getImageResource()和verify()接口不带seed参数
  * @expectedException PHPUnit_Framework_Error
  */
 public function testBlankSeed()
 {
     $captcha = new LtCaptcha();
     $config['captcha.allow_chars'] = "23456789abcdeghkmnpqsuvxyz";
     $config['captcha.length'] = 4;
     $config['captcha.image_engine'] = 'LtCaptchaImageEngine';
     $config['captcha.image_engine_conf'] = array('blur' => false, 'scale' => 2, 'width' => 200, 'height' => 80, 'max_rotation' => 4);
     $captcha->configHandle->addConfig($config);
     $captcha->init();
     $im = $captcha->getImageResource("");
 }
 /**
  * 测试verify接口是否能正常工作
  */
 public function testVerify()
 {
     $cp = new LtCaptcha();
     $config['captcha.allow_chars'] = "23456789abcdeghkmnpqsuvxyz";
     $config['captcha.length'] = 4;
     $config['captcha.image_engine'] = 'LtCaptchaImageEngine';
     $config['captcha.image_engine_conf'] = array('blur' => false, 'scale' => 2, 'width' => 200, 'height' => 80, 'max_rotation' => 4);
     $cp->configHandle->addConfig($config);
     $cp->init();
     $seed = md5(uniqid());
     $cp->getImageResource($seed);
     $word = $cp->storeHandle->get($seed);
     $this->assertTrue($cp->verify($seed, $word));
 }
Esempio n. 3
0
<?php

/**
 * 加载Captcha类文件
 */
$lotusHome = substr(__FILE__, 0, strpos(__FILE__, "example")) . '/';
include $lotusHome . "runtime/Config.php";
include $lotusHome . "runtime/Store.php";
include $lotusHome . "runtime/StoreMemory.php";
include $lotusHome . "runtime/StoreFile.php";
include $lotusHome . "runtime/Captcha/Captcha.php";
include $lotusHome . "runtime/Captcha/CaptchaImageEngine.php";
/**
 * 加载Captcha类文件
 */
/**
 * 开始使用Captcha
 */
$captcha = new LtCaptcha();
$config['captcha.seed_file_root'] = "/tmp/Lotus/captcha/seed/";
$config['captcha.allow_chars'] = "23456789abcdeghkmnpqsuvxyz";
$config['captcha.length'] = 4;
$config['captcha.image_engine'] = 'LtCaptchaImageEngine';
$config['captcha.image_engine_conf'] = array('blur' => false, 'scale' => 2, 'width' => 200, 'height' => 80, 'max_rotation' => 4);
$captcha->configHandle->addConfig($config);
$captcha->init();