mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Tests added
This commit is contained in:
@ -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]);
|
||||
|
Reference in New Issue
Block a user