Exemple #1
0
 public function testSetData_differentTimezones()
 {
     $field = new DateField('name', array('data_timezone' => 'America/New_York', 'user_timezone' => 'Pacific/Tahiti', 'type' => DateField::STRING, 'widget' => 'input'));
     $field->setLocale('de_AT');
     $field->setData('2010-06-02');
     $this->assertEquals('01.06.2010', $field->getDisplayedData());
 }
 public function testIsPartiallyFilled_returnsTrueIfChoiceAndDayEmpty()
 {
     $field = new DateField('name', array('data_timezone' => 'UTC', 'user_timezone' => 'UTC', 'widget' => 'choice'));
     $field->submit(array('day' => '', 'month' => '6', 'year' => '2010'));
     $this->assertTrue($field->isPartiallyFilled());
 }
Exemple #3
0
 public function testIsDayWithinRange_returnsFalseIfNotContained()
 {
     $field = new DateField('name', array('widget' => 'input', 'days' => array(6, 8)));
     $field->setLocale('de_AT');
     $field->bind('7.6.2010');
     $this->assertFalse($field->isDayWithinRange());
 }
Exemple #4
0
    public function testRenderAsChoiceWithPattern()
    {
        $field = new DateField('name', array('years' => array(2010, 2011), 'months' => array(6, 7), 'days' => array(1, 2), 'widget' => DateField::CHOICE, 'pattern' => '%day%---%month%---%year%'));
        $html = <<<EOF
<select id="name_day" name="name[day]">
<option value="1">01</option>
<option value="2">02</option>
</select>---<select id="name_month" name="name[month]">
<option value="6">06</option>
<option value="7">07</option>
</select>---<select id="name_year" name="name[year]">
<option value="2010">2010</option>
<option value="2011">2011</option>
</select>
EOF;
        $this->assertEquals($html, $field->render());
    }