Create AbstractFilterRule test

This commit is contained in:
Emmerson 2015-10-29 00:48:56 -03:00 committed by Henrique Moody
parent b7684b42f5
commit 6f77f8ac9b
2 changed files with 46 additions and 1 deletions

View 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([]));
}
}

View file

@ -33,4 +33,4 @@ class AbstractRegexRuleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(0, $regexRuleMock->validateClean('Validation'));
}
}
}