mirror of
https://github.com/Respect/Validation.git
synced 2026-03-22 17:54:41 +01:00
57 lines
No EOL
1.1 KiB
PHP
57 lines
No EOL
1.1 KiB
PHP
<?php
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
class DigitsTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
|
|
protected $object;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->object = new Digits;
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForDigits
|
|
*
|
|
*/
|
|
public function testDigits($input)
|
|
{
|
|
$this->assertTrue($this->object->assert($input));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForNotDigits
|
|
* @expectedException Respect\Validation\Exceptions\DigitsException
|
|
*/
|
|
public function testNotDigits($input)
|
|
{
|
|
$this->assertTrue($this->object->assert($input));
|
|
}
|
|
|
|
public function providerForDigits()
|
|
{
|
|
return array(
|
|
array(165),
|
|
array(1650),
|
|
array('165'),
|
|
array('1650'),
|
|
);
|
|
}
|
|
|
|
public function providerForNotDigits()
|
|
{
|
|
return array(
|
|
array(null),
|
|
array('a'),
|
|
array(' '),
|
|
array('Foo'),
|
|
array(''),
|
|
array('12.1'),
|
|
array('-12'),
|
|
array(-12),
|
|
);
|
|
}
|
|
|
|
} |