Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
131 lines (111 sloc) 2.86 KB
<?php
namespace gordian\reefknot\input\validate\prop;
/**
* Test class for Luhn.
* Generated by PHPUnit on 2011-12-11 at 12:51:13.
*/
class LuhnTest extends \PHPUnit_Framework_TestCase
{
/**
* @var gordian\reefknot\input\validate\prop\Luhn
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp ()
{
$this -> object = new Luhn;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown ()
{
}
public function testIsValidNullPasses ()
{
$this -> object -> setData (NULL);
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidPasses ()
{
$this -> object -> setData (4111111111111111);
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidPasses2 ()
{
$this -> object -> setData (79927398713);
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidPasses3 ()
{
$this -> object -> setData (109);
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidPasses4 ()
{
$this -> object -> setData (109.0);
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidPasses5 ()
{
$this -> object -> setData ('4111111111111111');
$this -> assertTrue ($this -> object -> isValid ());
}
public function testIsValidFails ()
{
$this -> object -> setData (4111111111111119);
$this -> assertFalse ($this -> object -> isValid ());
}
public function testIsValidFails2 ()
{
$this -> object -> setData (79927398714);
$this -> assertFalse ($this -> object -> isValid ());
}
public function testIsValidFails3 ()
{
$this -> object -> setData (108);
$this -> assertFalse ($this -> object -> isValid ());
}
public function testIsValidFails4 ()
{
$this -> object -> setData (108.0);
$this -> assertFalse ($this -> object -> isValid ());
}
public function testIsValidFails5 ()
{
$this -> object -> setData ('4111111111111119');
$this -> assertFalse ($this -> object -> isValid ());
}
public function testIsValidWrongTypeThrowsException ()
{
$exception = NULL;
$this -> object -> setData ('123 The quick brown fox jumps over the lazy dog 321');
try
{
$this -> object -> isValid ();
}
catch (\Exception $e)
{
$exception = $e;
}
$this -> assertTrue ($exception instanceof \InvalidArgumentException);
}
public function testIsValidWrongTypeThrowsException2 ()
{
$exception = NULL;
$this -> object -> setData (array (4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));
try
{
$this -> object -> isValid ();
}
catch (\Exception $e)
{
$exception = $e;
}
$this -> assertTrue ($exception instanceof \InvalidArgumentException);
}
}