mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class NumericTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
protected $object;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->object = new Numeric;
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForNumeric
|
|
*
|
|
*/
|
|
public function testNumeric($input)
|
|
{
|
|
$this->assertTrue($this->object->__invoke($input));
|
|
$this->assertTrue($this->object->check($input));
|
|
$this->assertTrue($this->object->assert($input));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForNotNumeric
|
|
* @expectedException Respect\Validation\Exceptions\NumericException
|
|
*/
|
|
public function testNotNumeric($input)
|
|
{
|
|
$this->assertFalse($this->object->__invoke($input));
|
|
$this->assertFalse($this->object->assert($input));
|
|
}
|
|
|
|
public function providerForNumeric()
|
|
{
|
|
return array(
|
|
array(''),
|
|
array(165),
|
|
array(165.0),
|
|
array(-165),
|
|
array('165'),
|
|
array('165.0'),
|
|
array('+165.0'),
|
|
);
|
|
}
|
|
|
|
public function providerForNotNumeric()
|
|
{
|
|
return array(
|
|
array(null),
|
|
array('a'),
|
|
array(' '),
|
|
array('Foo'),
|
|
);
|
|
}
|
|
}
|
|
|