Files
yii/tests/framework/validators/CRangeValidatorTest.php
Alexander Makarov 03fb457d9c fixed test
2013-06-12 14:41:56 +04:00

36 lines
1.0 KiB
PHP

<?php
require_once('ValidatorTestModel.php');
class CRangeValidatorTest extends CTestCase
{
public function testEmpty()
{
$model = new ValidatorTestModel('CRangeValidatorTest');
$model->string1 = '';
$model->string2 = '';
$model->validate(array('string1','string2'));
$this->assertArrayHasKey('string1', $model->getErrors());
$this->assertArrayNotHasKey('string2', $model->getErrors());
}
public function testZeroString()
{
$model = new ValidatorTestModel('CRangeValidatorTest');
$model->string1 = '0';
$model->string2 = '0';
$model->validate(array('string1','string2'));
$this->assertArrayNotHasKey('string1', $model->getErrors());
$this->assertArrayHasKey('string2', $model->getErrors());
}
public function testZeroNumber()
{
$model = new ValidatorTestModel('CRangeValidatorTest');
$model->string1 = 0;
$model->string2 = 0;
$model->validate(array('string1','string2'));
$this->assertArrayNotHasKey('string1', $model->getErrors());
$this->assertArrayHasKey('string2', $model->getErrors());
}
}