/** * Creates a countdown to the next upcoming event. * * @return string HTML code of the countdown or a message if no upcoming event has been found */ public function render() { if ($this->mapper === NULL) { throw new BadMethodCallException('The method injectEventMapper() needs to be called first.', 1333617194); } if ($this->viewHelper === NULL) { /** @var tx_seminars_ViewHelper_Countdown $viewHelper */ $viewHelper = t3lib_div::makeInstance('tx_seminars_ViewHelper_Countdown'); $this->injectCountDownViewHelper($viewHelper); } $this->setErrorMessage($this->checkConfiguration(TRUE)); try { /** @var tx_seminars_Model_Event $event */ $event = $this->mapper->findNextUpcoming(); $message = $this->viewHelper->render($event->getBeginDateAsUnixTimeStamp()); } catch (tx_oelib_Exception_NotFound $exception) { $message = $this->translate('message_countdown_noEventFound'); } $this->setMarker('count_down_message', $message); return $this->getSubpart('COUNTDOWN'); }
/** * @test */ public function findNextUpcomingWithTwoUpcomingEventsReturnsOnlyModelOfNextUpcomingEvent() { $this->testingFramework->createRecord('tx_seminars_seminars', array('begin_date' => $GLOBALS['SIM_ACCESS_TIME'] + 2000)); $uid = $this->testingFramework->createRecord('tx_seminars_seminars', array('begin_date' => $GLOBALS['SIM_ACCESS_TIME'] + 1000)); self::assertSame($uid, $this->fixture->findNextUpcoming()->getUid()); }