Add unit tests for date_format validator rule.
This commit is contained in:
parent
a56f0b2fb3
commit
49331d74e2
|
@ -483,6 +483,28 @@ public function testExistsRule()
|
|||
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the date_format validation rule.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testTheDateFormatRule()
|
||||
{
|
||||
$input = array('date' => '15-Feb-2009');
|
||||
$rules = array('date' => 'date_format:j-M-Y');
|
||||
$this->assertTrue(Validator::make($input, $rules)->valid());
|
||||
|
||||
$input['date'] = '2009-02-15 15:16:17';
|
||||
$rules = array('date' => 'date_format:Y-m-d H\\:i\\:s');
|
||||
$this->assertTrue(Validator::make($input, $rules)->valid());
|
||||
|
||||
$input['date'] = '2009-02-15';
|
||||
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||
|
||||
$input['date'] = '15:16:17';
|
||||
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the validator sets the correct messages.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue