mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 17:50:13 +02:00
Remove Int validator
This commit is contained in:
parent
afb16fcb60
commit
b883a2ac7b
|
@ -9,9 +9,7 @@ class Even extends AbstractRule
|
|||
|
||||
public function validate($input)
|
||||
{
|
||||
$int = new Int();
|
||||
$int->assert($input);
|
||||
|
||||
$input = (int) $input;
|
||||
return ($input % 2 == 0);
|
||||
}
|
||||
|
||||
|
@ -47,4 +45,4 @@ class Even extends AbstractRule
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Rules\Int;
|
||||
|
||||
class Odd extends AbstractRule
|
||||
{
|
||||
|
||||
public function validate($input)
|
||||
{
|
||||
$int = new Int();
|
||||
$int->assert($input);
|
||||
|
||||
$input = (int) $input;
|
||||
return ($input % 2 != 0);
|
||||
}
|
||||
|
||||
|
@ -47,4 +43,4 @@ class Odd extends AbstractRule
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -29,16 +29,7 @@ class EvenTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->assertTrue($this->object->assert($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForNotInt
|
||||
* @expectedException Respect\Validation\Exceptions\IntException
|
||||
*/
|
||||
public function testNotInt($input)
|
||||
{
|
||||
$this->assertTrue($this->object->assert($input));
|
||||
}
|
||||
|
||||
|
||||
public function providerForEven()
|
||||
{
|
||||
return array(
|
||||
|
@ -59,17 +50,4 @@ class EvenTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function providerForNotInt()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array('a'),
|
||||
array(' '),
|
||||
array('Foo'),
|
||||
array(''),
|
||||
array('1.44'),
|
||||
array(1e-5),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,15 +30,6 @@ class OddTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue($this->object->assert($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForNotInt
|
||||
* @expectedException Respect\Validation\Exceptions\IntException
|
||||
*/
|
||||
public function testNotInt($input)
|
||||
{
|
||||
$this->assertTrue($this->object->assert($input));
|
||||
}
|
||||
|
||||
public function providerForOdd()
|
||||
{
|
||||
return array(
|
||||
|
@ -59,17 +50,4 @@ class OddTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function providerForNotInt()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array('a'),
|
||||
array(' '),
|
||||
array('Foo'),
|
||||
array(''),
|
||||
array('1.44'),
|
||||
array(1e-5),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue