tests to disprove that input date and partial dateFormat does not work

This commit is contained in:
euromark 2013-06-25 11:54:29 +02:00
parent 468eb94e94
commit 290c343a74

View file

@ -6628,6 +6628,61 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals($result, $expected);
}
/**
* testInputDate method
*
* Test various inputs with type date and different dateFormat values
*
* @return void
*/
public function testInputDate() {
$this->Form->request->data = array();
$this->Form->create('User');
$result = $this->Form->input('month_year',
array(
'label' => false,
'div' => false,
'type' => 'date',
'dateFormat' => 'MY',
'minYear' => 2006,
'maxYear' => 2008
)
);
$this->assertContains('value="' . date('m') . '" selected="selected"', $result);
$this->assertContains('value="2008" selected="selected"', $result);
$result = $this->Form->input('just_year',
array(
'type' => 'date',
'label' => false,
'dateFormat' => 'Y',
'minYear' => date('Y'),
'maxYear' => date('Y', strtotime('+20 years'))
)
);
$this->assertContains('value="' . date('Y') . '" selected="selected"', $result);
$result = $this->Form->input('just_month',
array(
'type' => 'date',
'label' => false,
'dateFormat' => 'M',
'empty' => false,
)
);
$this->assertContains('value="' . date('m') . '" selected="selected"', $result);
$result = $this->Form->input('just_day',
array(
'type' => 'date',
'label' => false,
'dateFormat' => 'D',
'empty' => false,
)
);
$this->assertContains('value="' . date('d') . '" selected="selected"', $result);
}
/**
* testInputDateMaxYear method
*