miniflux-legacy/vendor/fguillot/simple-validator/tests/IntegerValidatorTest.php

28 lines
1001 B
PHP
Raw Normal View History

<?php
use SimpleValidator\Validators\Integer;
class IntegerValidatorTest extends PHPUnit_Framework_TestCase
{
public function testValidator()
{
$message = 'field must be an integer';
$v = new Integer('toto', $message);
$this->assertEquals($message, $v->getErrorMessage());
$this->assertTrue($v->execute(array('toto' => '')));
$this->assertTrue($v->execute(array('toto' => null)));
$this->assertFalse($v->execute(array('toto' => 'ddgg')));
$this->assertFalse($v->execute(array('toto' => '123.4')));
$this->assertFalse($v->execute(array('toto' => 123.4)));
$this->assertTrue($v->execute(array()));
$this->assertTrue($v->execute(array('toto' => 123)));
$this->assertTrue($v->execute(array('toto' => -123)));
$this->assertTrue($v->execute(array('toto' => '-123')));
$this->assertTrue($v->execute(array('toto' => 0)));
$this->assertTrue($v->execute(array('toto' => '0')));
}
2015-04-11 02:34:48 +02:00
}