本文整理汇总了PHP中DateRange::getErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP DateRange::getErrorMessage方法的具体用法?PHP DateRange::getErrorMessage怎么用?PHP DateRange::getErrorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateRange
的用法示例。
在下文中一共展示了DateRange::getErrorMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFilterTo
public function testFilterTo()
{
$to = new \DateTime('2010-10-12 08:30:00');
$filter = new DateRange(null, $to);
// test between
$this->assertEquals(new \DateTime('2010-10-11 06:00:00'), $filter->apply('2010-10-11 06:00:00'));
// test to
$this->assertEquals(new \DateTime('2010-10-12 08:29:59'), $filter->apply('2010-10-12 08:29:59'));
$this->assertEquals(new \DateTime('2010-10-12 08:30:00'), $filter->apply('2010-10-12 08:30:00'));
$this->assertEquals(false, $filter->apply('2010-10-12 08:30:01'));
// test error message
$this->assertErrorMessage($filter->getErrorMessage());
}
示例2: testErrorMessageIsCustomizable
public function testErrorMessageIsCustomizable()
{
$constraint = new DateRange('today', '+3days', 'CUSTOM!');
$this->assertSame('[field] CUSTOM!', $constraint->getErrorMessage('field'));
}
示例3: testIsGettingErrorMessage
public function testIsGettingErrorMessage()
{
$constraint = new DateRange('today', '+3 days');
$this->assertFalse($constraint->validate('yesterday'));
$this->assertEquals('[field] Date is not between "today" and "+3 days"', $constraint->getErrorMessage('field'));
}