public function setUp() { $this->factory = new Tx_CzSimpleCal_Recurrance_Factory_Mock(); $this->events = new Tx_CzSimpleCal_Recurrance_Timeline_Event_Mock(); $this->events->setEvent(new Tx_CzSimpleCal_Domain_Model_Event()); $this->exceptions = new Tx_CzSimpleCal_Recurrance_Timeline_Exception(); }
public function testAddingOfEvent() { $event = new Tx_CzSimpleCal_Domain_Model_Event(); $this->timeline->setEvent($event); $this->timeline->add(array('start' => strtotime('2009-02-13 23:31:30GMT'), 'end' => strtotime('2009-02-13 23:31:31GMT'))); $current = $this->timeline->current(); self::assertArrayHasKey('event', $current, 'data gets key "event"'); self::assertArrayHasKey('pid', $current, 'data gets key "pid"'); }
/** * build the recurrance for all events paying no attention to exceptions * * @return Tx_CzSimpleCal_Recurrance_Timeline_Event */ protected function buildEventTimeline() { $type = $this->event->getRecurranceType(); if (empty($type)) { throw new RuntimeException('The recurrance_type should not be empty.'); } $className = 'Tx_CzSimpleCal_Recurrance_Type_' . \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($type); if (!class_exists($className)) { throw new BadMethodCallException(sprintf('The class %s does not exist for creating recurring events.', $className)); } $class = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className); if (!$class instanceof Tx_CzSimpleCal_Recurrance_Type_Base) { throw new BadMethodCallException(sprintf('The class %s does not implement the Tx_CzSimpleCal_Recurrance_Type_Base.', get_class($class))); } $eventTimeline = new Tx_CzSimpleCal_Recurrance_Timeline_Event(); $eventTimeline->setEvent($this->event); return $class->build($this->event, $eventTimeline); }