Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 290c343a745074f1955dd39f7a83638e144df8d8 1 parent 468eb94
@dereuromark dereuromark authored
Showing with 55 additions and 0 deletions.
  1. +55 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
View
55 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -6629,6 +6629,61 @@ public function testYearAutoExpandRange() {
}
/**
+ * 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
*
* Let's say we want to only allow users born from 2006 to 2008 to register
Please sign in to comment.
Something went wrong with that request. Please try again.