/** * Tests whether certain edge cases return the right identifier when looking at. */ public function testEdgeCases() { //test whether something between brackets is ignored $result1 = Stations::getStations('Brussel Nat (be)'); $this->assertCount(1, $result1->{'@graph'}); //test whether sint st. and saint return the same result $result2a = Stations::getStations('st pancras'); $result2b = Stations::getStations('saint pancras'); $result2c = Stations::getStations('st-pancras'); $result2d = Stations::getStations('st.-pancras'); $this->assertEquals($result2a->{'@graph'}[0]->{'@id'}, $result2b->{'@graph'}[0]->{'@id'}); $this->assertEquals($result2b->{'@graph'}[0]->{'@id'}, $result2c->{'@graph'}[0]->{'@id'}); $this->assertEquals($result2a->{'@graph'}[0]->{'@id'}, $result2d->{'@graph'}[0]->{'@id'}); // Check whether both am main and main work $result3a = Stations::getStations('frankfurt am main'); $result3b = Stations::getStations('frankfurt main'); $this->assertEquals($result3a->{'@graph'}[0]->{'@id'}, $result3b->{'@graph'}[0]->{'@id'}); // Check whether flughhaven am main don't get mixed up and all work $result4a = Stations::getStations('frankfurt am main flughafen'); $result4b = Stations::getStations('frankfurt flughafen'); $result4c = Stations::getStations('frankfurt main flughafen'); $this->assertEquals($result4a->{'@graph'}[0]->{'@id'}, $result4b->{'@graph'}[0]->{'@id'}); $this->assertEquals($result4b->{'@graph'}[0]->{'@id'}, $result4c->{'@graph'}[0]->{'@id'}); $result5a = Stations::getStations("braine l'alleud"); $result5b = Stations::getStations('braine l alleud'); //for hafas purposes: https://github.com/iRail/hyperRail/issues/129 $this->assertEquals($result5a->{'@graph'}[0]->{'@id'}, $result5b->{'@graph'}[0]->{'@id'}); }
public function testSort() { //test whether Ghent Sint Pieters is the first object when searching for Belgian stations in a sorted fashion $results = Stations::getStations('Gent', 'be', true); $result1 = $results->{'@graph'}[0]; $ghentsp = Stations::getStationFromID('http://irail.be/stations/NMBS/008892007'); $this->assertEquals($result1->{'name'}, $ghentsp->{'name'}); $results = Stations::getStations('Brussel', '', true); $result2 = $results->{'@graph'}[0]; //The busiest station in Brussels is the south one $brusselssouth = Stations::getStations('Brussels South')->{'@graph'}[0]; $this->assertEquals($result2->{'name'}, $brusselssouth->{'name'}); }