mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
Add test to exhibit error behavior
This commit is contained in:
parent
2e8453be81
commit
8f364b89a8
@ -578,6 +578,32 @@ class ValidateTest extends BaseTestCase
|
||||
$this->assertTrue($v->validate());
|
||||
}
|
||||
|
||||
public function testDateWarningsWithObjectParams()
|
||||
{
|
||||
$v = new Validator(array('startDate' => '2013-01-27', 'endDate' => '2013-05-08'));
|
||||
$v->rule(
|
||||
'date',
|
||||
[
|
||||
'startDate',
|
||||
'endDate'
|
||||
]
|
||||
);
|
||||
|
||||
$v->rule(
|
||||
'dateBefore',
|
||||
'endDate',
|
||||
new DateTime('2013-04-08')
|
||||
)->label('End date')->message('{field} must be before the end of the fiscal year, %s.');
|
||||
|
||||
$v->rule(
|
||||
'dateAfter',
|
||||
'startDate',
|
||||
new DateTime('2013-02-17')
|
||||
)->label('Start date')->message('{field} must be after the beginning of the fiscal year, %s.');
|
||||
|
||||
$this->assertFalse($v->validate());
|
||||
}
|
||||
|
||||
public function testDateBeforeInvalid()
|
||||
{
|
||||
$v = new Validator(array('date' => '2013-01-27'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user