Create AbstractRegexRule test

This commit is contained in:
Emmerson 2015-10-29 00:12:15 -03:00 committed by Henrique Moody
parent bb02f5ef43
commit b7684b42f5

View file

@ -0,0 +1,36 @@
<?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;
class AbstractRegexRuleTest extends \PHPUnit_Framework_TestCase
{
public function testValidateCleanShouldReturnOneIfPatternIsFound()
{
$regexRuleMock = $this->getMockForAbstractClass('Respect\\Validation\\Rules\\AbstractRegexRule');
$regexRuleMock->expects($this->any())
->method('getPregFormat')
->will($this->returnValue('/^Respect$/'));
$this->assertEquals(1, $regexRuleMock->validateClean('Respect'));
}
public function testValidateCleanShouldReturnZeroIfPatternIsNotFound()
{
$regexRuleMock = $this->getMockForAbstractClass('Respect\\Validation\\Rules\\AbstractRegexRule');
$regexRuleMock->expects($this->any())
->method('getPregFormat')
->will($this->returnValue('/^Respect$/'));
$this->assertEquals(0, $regexRuleMock->validateClean('Validation'));
}
}