yiiapi/tests/framework/validators/CDateValidatorTest.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
require_once 'ModelMock.php';
/**
* CDateValidatorTest
*
* @author Kevin Bradwick <kbradwick@gmail.com>
*/
class CDateValidatorTest extends CTestCase
{
/**
* Test allow empty
*
* @return null
*/
public function testAllowEmptyOption()
{
$model = $this->getModelMock(array('allowEmpty' => true));
$this->assertTrue($model->validate());
$model = $this->getModelMock(array('allowEmpty' => false));
$this->assertFalse($model->validate());
$this->assertTrue($model->hasErrors('foo'));
}
/**
* Test can validate different formats
*
* @return null
*/
public function testFormatOption()
{
// default format
$model = $this->getModelMock();
$model->foo = '01/01/2011';
$this->assertTrue($model->validate());
$model->foo = '42/01/2011';
$this->assertFalse($model->validate());
// custom format
$model = $this->getModelMock(array('format' => 'dd-MM-yyyy'));
$model->foo = '01-01-2011';
$this->assertTrue($model->validate());
$model->foo = '01-24-2011';
$this->assertFalse($model->validate());
// array value, https://github.com/yiisoft/yii/issues/1955
$model->foo = array('01-01-2011');
$this->assertFalse($model->validate());
}
/**
* Test the timestamp option
*
* @return null
*/
public function testTimestampOption()
{
$model = $this->getModelMock(array('timestampAttribute' => 'bar'));
后面还有 31 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
