/** * {@inheritDoc} */ public function getTimetable(TimetableQueryInterface $query) { $parser = $this->getProvider()->getTimetableParser($query); $timetable = new Timetable(new Station($query->getDepartureId(), $parser->getDepartureName(), $query->getRouteId()), new Station($query->getDestinationId(), $parser->getDestinationName(), $query->getRouteId()), $parser->getTransferName()); foreach ($parser->getTrips() as $trip) { $timetable->addTrip($trip); } return $timetable; }
public function testGetDate() { $departure = new Station(1, "From", 61); $destination = new Station(2, "To", 61); $timetable = new Timetable($departure, $destination); $this->assertNull($timetable->getDate()); $timetable->addTrip(new Trip(new Train("c1", new \DateTime("2014-07-15 12:00:00"), new \DateTime("2014-07-15 12:45:00")))); $expectedDate = new \DateTime("2014-07-15 00:00:00"); $this->assertEquals($expectedDate, $timetable->getDate()); }