Skip to content

Commit

Permalink
tests to disprove that input date and partial dateFormat does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Jun 25, 2013
1 parent 468eb94 commit 290c343
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -6628,6 +6628,61 @@ public function testYearAutoExpandRange() {
$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
*
Expand Down

0 comments on commit 290c343

Please sign in to comment.