/** * test grabbing a notification by invalid notificationDateTime **/ public function testGetInvalidNotificationByNotificationDateTime() { // grab the data from mySQL and enforce the fields match our expectations $angularDate = $this->VALID_notificationDateTime->getTimestamp() * 1000; $response = $this->guzzle->get('http://bootcamp-coders.cnm.edu/~invtext/backend/php/api/notification/?date=' . $angularDate); $this->assertSame($response->getStatusCode(), 200); $body = $response->getBody(); $notification = json_decode($body); $this->assertSame(200, $notification->status); }
/** * Returns all CourseMarkedEvents in the given time range for the given range_id. * * @param string $user_id Id of Stud.IP object from type user, course, inst * @param DateTime $start The start date time. * @param DateTime $end The end date time. * @return SimpleORMapCollection Collection of found CourseMarkedEvents. */ public static function getEventsByInterval($user_id, DateTime $start, dateTime $end) { $stmt = DBManager::get()->prepare('SELECT DISTINCT termine.* FROM schedule_seminare ' . 'INNER JOIN termine ON schedule_seminare.seminar_id = range_id ' . 'LEFT JOIN seminar_user ON seminar_user.seminar_id = range_id AND seminar_user.user_id= :user_id ' . 'WHERE schedule_seminare.user_id = :user_id AND schedule_seminare.visible = 1 ' . 'AND seminar_user.seminar_id IS NULL AND date BETWEEN :start AND :end ' . 'ORDER BY date ASC'); $stmt->execute(array(':user_id' => $user_id, ':start' => $start->getTimestamp(), ':end' => $end->getTimestamp())); $event_collection = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $event = new CourseMarkedEvent(); $event->setData($row); $event->setNew(false); $event_collection[] = $event; } $event_collection = SimpleORMapCollection::createFromArray($event_collection, false); $event_collection->setClassName('Event'); return $event_collection; }
/** * Returns all CourseEvents in the given time range for the given range_id. * * @param string $user_id Id of Stud.IP object from type user, course, inst * @param DateTime $start The start date time. * @param DateTime $end The end date time. * @return SimpleORMapCollection Collection of found CourseEvents. */ public static function getEventsByInterval($user_id, DateTime $start, dateTime $end) { $stmt = DBManager::get()->prepare('SELECT termine.* FROM seminar_user ' . 'INNER JOIN termine ON seminar_id = range_id ' . 'WHERE user_id = :user_id ' . 'AND date BETWEEN :start AND :end ' . "AND (IFNULL(metadate_id, '') = '' " . 'OR metadate_id NOT IN ( ' . 'SELECT metadate_id FROM schedule_seminare ' . 'WHERE user_id = :user_id AND visible = 0) ) ' . 'ORDER BY date ASC'); $stmt->execute(array(':user_id' => $user_id, ':start' => $start->getTimestamp(), ':end' => $end->getTimestamp())); $event_collection = array(); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) { $event = new CourseEvent(); $event->setData($row); $event->setNew(false); // related persons (dozenten) or groups if (self::checkRelated($event, $user_id)) { $event_collection[] = $event; } } $event_collection = SimpleORMapCollection::createFromArray($event_collection, false); $event_collection->setClassName('Event'); return $event_collection; }
/** * determines which variables to include in json_encode() * * @see http://php.net/manual/en/class.jsonserializable.php JsonSerializable interface * @return array all object variables, including private variables **/ public function JsonSerialize() { $fields = get_object_vars($this); $fields["notificationDateTime"] = $this->notificationDateTime->getTimestamp() * 1000; return $fields; }