Commit 460b5fab by Alexander Kochetov

Tests added

parent d479f317
......@@ -41,6 +41,17 @@ class RangeValidatorTest extends TestCase
$this->assertTrue($val->validate("5"));
}
public function testValidateArrayValue()
{
$val = new RangeValidator(['range' => range(1, 10, 1)]);
$val->allowArray = true;
$this->assertTrue($val->validate([1, 2, 3, 4, 5]));
$this->assertTrue($val->validate([6, 7, 8, 9, 10]));
$this->assertFalse($val->validate([0, 1, 2]));
$this->assertFalse($val->validate([10, 11, 12]));
$this->assertTrue($val->validate(["1", "2", "3", 4, 5, 6]));
}
public function testValidateValueStrict()
{
$val = new RangeValidator(['range' => range(1, 10, 1), 'strict' => true]);
......@@ -52,6 +63,14 @@ class RangeValidatorTest extends TestCase
$this->assertFalse($val->validate("5.5"));
}
public function testValidateArrayValueStrict()
{
$val = new RangeValidator(['range' => range(1, 10, 1), 'strict' => true]);
$val->allowArray = true;
$this->assertFalse($val->validate(["1", "2", "3", "4", "5", "6"]));
$this->assertFalse($val->validate(["1", "2", "3", 4, 5, 6]));
}
public function testValidateValueNot()
{
$val = new RangeValidator(['range' => range(1, 10, 1), 'not' => true]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment