mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 23:59:51 +01:00
79 lines
1.9 KiB
PHP
79 lines
1.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Respect/Validation.
|
|
*
|
|
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
|
|
*
|
|
* For the full copyright and license information, please view the "LICENSE.md"
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
/**
|
|
* @group rule
|
|
* @covers Respect\Validation\Rules\Roman
|
|
* @covers Respect\Validation\Exceptions\RomanException
|
|
*/
|
|
class RomanTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
protected $romanValidator;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->romanValidator = new Roman();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForRoman
|
|
*/
|
|
public function testValidRomansShouldReturnTrue($input)
|
|
{
|
|
$this->assertTrue($this->romanValidator->__invoke($input));
|
|
$this->assertTrue($this->romanValidator->assert($input));
|
|
$this->assertTrue($this->romanValidator->check($input));
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerForNotRoman
|
|
* @expectedException Respect\Validation\Exceptions\RomanException
|
|
*/
|
|
public function testInvalidRomansShouldThrowRomanException($input)
|
|
{
|
|
$this->assertFalse($this->romanValidator->__invoke($input));
|
|
$this->assertFalse($this->romanValidator->assert($input));
|
|
}
|
|
|
|
public function providerForRoman()
|
|
{
|
|
return array(
|
|
array(''),
|
|
array('III'),
|
|
array('IV'),
|
|
array('VI'),
|
|
array('XIX'),
|
|
array('XLII'),
|
|
array('LXII'),
|
|
array('CXLIX'),
|
|
array('CLIII'),
|
|
array('MCCXXXIV'),
|
|
array('MMXXIV'),
|
|
array('MCMLXXV'),
|
|
array('MMMMCMXCIX'),
|
|
);
|
|
}
|
|
|
|
public function providerForNotRoman()
|
|
{
|
|
return array(
|
|
array(' '),
|
|
array('IIII'),
|
|
array('IVVVX'),
|
|
array('CCDC'), //
|
|
array('MXM'),
|
|
array('XIIIIIIII'),
|
|
array('MIMIMI'),
|
|
);
|
|
}
|
|
}
|