Add unit tests for date_format validator rule.

This commit is contained in:
Franz Liedke 2012-09-07 14:01:45 +02:00
parent a56f0b2fb3
commit 49331d74e2
1 changed files with 22 additions and 0 deletions

View File

@ -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.
*