/** * @param int $uid * @param string $begin * @param string $end * @param array $speakerIds * @param bool $expected * * @test * @dataProvider collidingSessionsAreDeterminedDataProvider */ public function collidingSessionsAreDetermined($uid, $begin, $end, array $speakerIds, $exclude, $expected) { $beginDateTime = \DateTime::createFromFormat(DATE_ISO8601, $begin); $endDateTime = \DateTime::createFromFormat(DATE_ISO8601, $end); $session = new AnySession(); $session->_setProperty('uid', $uid); $session->setBegin($beginDateTime); $session->setEnd($endDateTime); foreach ($speakerIds as $speakerId) { $speaker = new FrontendUser(); $speaker->_setProperty('uid', $speakerId); $session->addSpeaker($speaker); } $result = $this->subject->getCollidingSessions($session, $exclude); $this->assertEquals($expected, is_array($result) ? count($result) : $result); }
/** * Fetches a simple array of sessions (with vote count not being transformed into an objectstorage) * for a simple list view. * @param $type * @return array */ protected function getFlatSessionObjects($type) { $sessions = []; /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */ $db = $GLOBALS['TYPO3_DB']; $stmt = $db->prepare_SELECTquery('uid AS __identity, title, description, highlight, ' . '(SELECT COUNT(tx_sessions_domain_model_vote.uid) ' . 'FROM tx_sessions_domain_model_vote ' . 'WHERE tx_sessions_domain_model_vote.session=tx_sessions_domain_model_session.uid) as votes', 'tx_sessions_domain_model_session', 'type = :type AND deleted = 0 ' . BackendUtility::BEenableFields('tx_sessions_domain_model_session'), '', 'votes DESC ', '', [':type' => ApiModuleController::$slugClassMap[$type]]); if ($stmt->execute()) { while ($row = $stmt->fetch(\TYPO3\CMS\Core\Database\PreparedStatement::FETCH_ASSOC)) { $row['speakers'] = $this->utility->getSpeakers($row['__identity']); $row['json'] = json_encode($row); $sessions[] = $row; } $stmt->free(); } return $sessions; }