/** * @test */ public function renderWithUidOfExistingEventReturnsHtmlSpecialCharedTitleOfSelectedEvent() { /** @var tx_seminars_Model_Event $event */ $event = $this->mapper->find($this->eventId); $event->setTitle('<test>Test event</test>'); $this->fixture->piVars['uid'] = $this->eventId; self::assertContains(htmlspecialchars('<test>Test event</test>'), $this->fixture->render()); }
/** * @test */ public function getDependenciesForEventTopicWithOneDependencyReturnsOneDependency() { $uid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_TOPIC)); $relatedUid = $this->testingFramework->createRecord('tx_seminars_seminars', array('object_type' => tx_seminars_Model_Event::TYPE_TOPIC)); $this->testingFramework->createRelationAndUpdateCounter('tx_seminars_seminars', $relatedUid, $uid, 'dependencies'); /** @var tx_seminars_Model_Event $model */ $model = $this->fixture->find($relatedUid); self::assertEquals($uid, $model->getDependencies()->getUids()); }
/** * @test */ public function renderCallsRenderMethodOfCountdownViewHelperWithNextUpcomingEventsBeginDateAsUnixTimeStamp() { $this->fixture->injectEventMapper($this->mapper); $event = $this->mapper->getLoadedTestingModel(array('object_type' => tx_seminars_Model_Event::TYPE_COMPLETE, 'pid' => 0, 'title' => 'Test event', 'begin_date' => $GLOBALS['SIM_ACCESS_TIME'] + 1000)); $this->mapper->expects(self::once())->method('findNextUpcoming')->will(self::returnValue($event)); $this->viewHelper = $this->getMock('tx_seminars_ViewHelper_Countdown', array('render')); $this->viewHelper->expects(self::once())->method('render')->with(self::equalTo($event->getBeginDateAsUnixTimeStamp())); $this->fixture->injectCountDownViewHelper($this->viewHelper); $this->fixture->render(); }
/** * Creates the event headline, consisting of the event title and date. * * @return string HTML code of the event headline, will be empty if an invalid or no event ID was set in piVar 'uid' */ public function render() { if ($this->mapper === NULL) { throw new BadMethodCallException("The method injectEventMapper() needs to be called first.", 1333614794); } $eventId = (int) $this->piVars['uid']; if ($eventId <= 0) { return ''; } /** @var tx_seminars_Model_Event $event */ $event = $this->mapper->find($eventId); if (!$this->mapper->existsModel($eventId)) { return ''; } $this->setMarker('title_and_date', $this->getTitleAndDate($event)); $result = $this->getSubpart('VIEW_HEADLINE'); $this->setErrorMessage($this->checkConfiguration(TRUE)); return $result; }
/** * 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 getDependenciesForSingleEventReturnsEmptyList() { self::assertTrue($this->fixture->getLoadedTestingModel(array('object_type' => tx_seminars_Model_Event::TYPE_COMPLETE))->getDependencies()->isEmpty()); }
/** * @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()); }