public function testGetHtmlSuccessfulTimestamp()
 {
     $uniqueHash = 'H@$H';
     $id = 3;
     $format = 'mm/dd/yyyy';
     $yesterday = new \DateTime();
     $yesterday->add(\DateInterval::createFromDateString('yesterday'));
     $tomorrow = new \DateTime();
     $tomorrow->add(\DateInterval::createFromDateString('tomorrow'));
     $value = ['locale' => 'en_US', 'from' => $yesterday->getTimestamp(), 'to' => $tomorrow->getTimestamp()];
     $this->mathRandomMock->expects($this->any())->method('getUniqueHash')->willReturn($uniqueHash);
     $this->columnMock->expects($this->once())->method('getHtmlId')->willReturn($id);
     $this->localeDateMock->expects($this->any())->method('getDateFormat')->willReturn($format);
     $this->columnMock->expects($this->any())->method('getTimezone')->willReturn(false);
     $this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en_US');
     $this->model->setColumn($this->columnMock);
     $this->model->setValue($value);
     $output = $this->model->getHtml();
     $this->assertContains('id="' . $uniqueHash . '_from" value="' . $yesterday->getTimestamp(), $output);
     $this->assertContains('id="' . $uniqueHash . '_to" value="' . $tomorrow->getTimestamp(), $output);
 }
 /**
  * Return escaped value for calendar
  *
  * @param string $index
  * @return string
  */
 public function getEscapedValue($index = null)
 {
     if ($this->getColumn()->getFilterTime()) {
         $value = $this->getValue($index);
         if ($value instanceof \DateTime) {
             return $this->_localeDate->formatDateTime($value);
         }
         return $value;
     }
     return parent::getEscapedValue($index);
 }
Exemple #3
0
 /**
  * Return escaped value for calendar
  *
  * @param string $index
  * @return string
  */
 public function getEscapedValue($index = null)
 {
     if ($this->getColumn()->getFilterTime()) {
         $value = $this->getValue($index);
         if ($value instanceof \Zend_Date) {
             return $value->toString($this->_localeDate->getDateTimeFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT));
         }
         return $value;
     }
     return parent::getEscapedValue($index);
 }