本文整理匯總了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'));
}