mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
Create AbstractFilterRule test
This commit is contained in:
parent
b7684b42f5
commit
6f77f8ac9b
45
tests/unit/Rules/AbstractFilterRuleTest.php
Normal file
45
tests/unit/Rules/AbstractFilterRuleTest.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?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 AbstractFilterRuleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Respect\Validation\Exceptions\ComponentException
|
||||
* @expectedExceptionMessage Invalid list of additional characters to be loaded
|
||||
*/
|
||||
public function testConstructorShouldThrowExceptionIfParamIsNotString()
|
||||
{
|
||||
$this->getMockForAbstractClass('Respect\\Validation\\Rules\\AbstractFilterRule', [1]);
|
||||
}
|
||||
|
||||
public function testValidateShouldReturnTrueForValidArguments()
|
||||
{
|
||||
$filterRuleMock = $this->getMockForAbstractClass('Respect\\Validation\\Rules\\AbstractFilterRule');
|
||||
$filterRuleMock->expects($this->any())
|
||||
->method('validateClean')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertTrue($filterRuleMock->validate('hey'));
|
||||
}
|
||||
|
||||
public function testValidateShouldReturnFalseForInvalidArguments()
|
||||
{
|
||||
$filterRuleMock = $this->getMockForAbstractClass('Respect\\Validation\\Rules\\AbstractFilterRule');
|
||||
$filterRuleMock->expects($this->any())
|
||||
->method('validateClean')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->assertFalse($filterRuleMock->validate(''));
|
||||
$this->assertFalse($filterRuleMock->validate([]));
|
||||
}
|
||||
}
|
|
@ -33,4 +33,4 @@ class AbstractRegexRuleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertEquals(0, $regexRuleMock->validateClean('Validation'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue