Пример #1
0
 public function testValueReturnedFromComposedDateTimeIsRfc3339FullDateFormat()
 {
     $element = new DateElement('foo');
     $date = new DateTime();
     $element->setValue($date);
     $value = $element->getValue();
     $this->assertEquals($date->format('Y-m-d'), $value);
 }
 public function getForm(array $formulaList)
 {
     if (!$this->form) {
         $fromDate = new Element\Date('fromDate');
         $fromDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $fromDate->setValue(date('Y-m-26', strtotime('-1 month')));
         $toDate = new Element\Date('toDate');
         $toDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;margin-left:5px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $toDate->setValue(date('Y-m-25', time('')));
         $formula = new Element\Select();
         $formula->setName('formula')->setAttribute('class', 'form-control')->setAttribute('style', 'width:200px')->setValueOptions($formulaList)->setEmptyOption('-- Choose Formula --');
         $form = new Form();
         $form->setAttributes(array('class' => 'form-inline', 'role' => 'form', 'id' => 'process-form'));
         $form->add($fromDate);
         $form->add($toDate);
         $form->add($formula);
         $this->form = $form;
     }
     return $this->form;
 }
Пример #3
0
 public function testErrorShowTwice()
 {
     $element = new Element\Date('birth');
     $element->setFormat('Y-m-d');
     $element->setValue('2010-13-13');
     $validator = new \Zend\Validator\Date();
     $validator->isValid($element->getValue());
     $element->setMessages($validator->getMessages());
     $markup = $this->helper->__invoke($element);
     $this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
 }