iRail / stations

A list of all the Belgian stations and their properties used within the iRail project
http://irail.be/stations/NMBS
29 stars 20 forks source link

Tests fail but succeed on PHP7 #101

Closed pietercolpaert closed 8 years ago

pietercolpaert commented 8 years ago

It's weird that our travis-ci build breaks on an edge-case, while this was not the case before. On my local machine all tests run successfully though.

pietercolpaert commented 8 years ago

It seems to be only a problem in travis? Anyone any idea?

Haroenv commented 8 years ago

I can replicate with

PHP 5.6.23 (cli) (built: Jun 24 2016 21:14:33) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

and "phpunit/phpunit": "^5.5"

Trying to find a fix.

Error is happening in the first part of that test:

//test whether something between brackets is ignored
$result1 = Stations::getStations('Brussel Nat (be)');
$this->assertCount(1, $result1->{'@graph'});

The var_dump of $result1 for me is:

object(stdClass)#866 (3) {
  ["@id"]=>
  string(48) "http://irail.be/stations/NMBS?q=Brussel Nat (be)"
  ["@context"]=>
  object(stdClass)#19 (6) {
    ["name"]=>
    string(30) "http://xmlns.com/foaf/0.1/name"
    ["longitude"]=>
    string(44) "http://www.w3.org/2003/01/geo/wgs84_pos#long"
    ["latitude"]=>
    string(43) "http://www.w3.org/2003/01/geo/wgs84_pos#lat"
    ["alternative"]=>
    string(36) "http://purl.org/dc/terms/alternative"
    ["country"]=>
    object(stdClass)#21 (2) {
      ["@type"]=>
      string(3) "@id"
      ["@id"]=>
      string(46) "http://www.geonames.org/ontology#parentCountry"
    }
    ["avgStopTimes"]=>
    string(48) "http://semweb.mmlab.be/ns/stoptimes#avgStopTimes"
  }
  ["@graph"]=>
  array(0) {
  }
}

Doesn't happen when I change Brussel Nat (be) to Brussels airport (be) or basically any other station

Suggested fix: not testing brussel nat, but testing brussels airport or replacing brussel nat to brussels airport in https://github.com/iRail/stations/blob/master/src/irail/stations/Stations.php#L39. Since Brussel Nat is no longer the official name it makes sense to me to update the test with the new name.