Skip to content

Commit

Permalink
extend numeral driver tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BigMichi1 committed Jul 24, 2013
1 parent d0724ba commit db1dba1
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/Text_CAPTCHA_Driver_Numeral_Test.php
Expand Up @@ -37,7 +37,6 @@ class Text_CAPTCHA_Driver_Numeral_Test extends PHPUnit_Framework_TestCase
protected function setUp()
{
$this->_captcha = Text_CAPTCHA::factory("Numeral");
$this->_captcha->init();
}

/**
Expand All @@ -47,7 +46,52 @@ protected function setUp()
*/
public function testSimple()
{
$this->_captcha->init();
$this->assertNotNull($this->_captcha->getCAPTCHA());
$this->assertNotNull($this->_captcha->getPhrase());
}

/**
* test min/maxValue
*
* @return void
*/
public function testMinMaxValue()
{
$this->_captcha->init(
array(
'minValue' => 52,
'maxValue' => 52,
'operator' => '-'
)
);
$this->assertNotNull($this->_captcha->getCAPTCHA());
$this->assertEquals(0, $this->_captcha->getPhrase());
}

/**
* test operator
*
* @return void
*/
public function testOperator()
{
$this->_captcha->init(array('operator' => '-'));
$captcha = $this->_captcha->getCAPTCHA();
$function = create_function('', 'return ' . $captcha . ';');
$this->assertNotNull($captcha);
$this->assertEquals($function(), $this->_captcha->getPhrase());

$this->_captcha->init(array('operator' => '+'));
$captcha = $this->_captcha->getCAPTCHA();
$function = create_function('', 'return ' . $captcha . ';');
$this->assertNotNull($captcha);
$this->assertEquals($function(), $this->_captcha->getPhrase());

$this->_captcha->init(array('operator' => '**'));
$captcha = $this->_captcha->getCAPTCHA();
$function = create_function('', 'return ' . $captcha . ';');
$this->assertNotNull($captcha);
$this->assertEquals($function(), $this->_captcha->getPhrase());
}
}

0 comments on commit db1dba1

Please sign in to comment.