public function __construct(Xhb $xhb, $data = array()) { $this->setLabel('Category'); parent::__construct($data); $this->_xhb = $xhb; $options = array(); foreach ($xhb->getCategoryCollection() as $key => $category) { $options[$key] = $this->_categoryToOptionArray($category); } $this->setOptions($options); }
public function testGetPredefinedTimePeriods_allDate() { $fixture = $this->xhb->getDateHelper(false); // ALL DATE $oldestOperationDate = $this->_getDateTime('now'); $mostRecentOperationDate = $this->_getDateTime('1970-01-01'); /* @var $op Operation */ foreach ($this->xhb->getOperationCollection() as $op) { if ($op->getDateModel() < $oldestOperationDate) { echo $op->getDateModel()->format('Y-m-d') . "\n"; $oldestOperationDate = $op->getDateModel(); } if ($op->getDateModel() > $mostRecentOperationDate) { $mostRecentOperationDate = $op->getDateModel(); } } $allDate = array('start' => $oldestOperationDate, 'end' => $mostRecentOperationDate); $periods = $fixture->getPredefinedTimePeriods(); $this->assertEquals($allDate, $periods[DateHelper::TIME_PERIOD_ALL_DATE]); }
/** * @param \DateTime $startDate * @param \DateTime $endDate * @return \DatePeriod */ public static function getDatePeriod(Xhb $xhb, \DateTime $startDate, \DateTime $endDate, \DateInterval $interval = null) { return $xhb->getDateHelper()->getDatePeriod($startDate, $endDate, $interval); }