Esempio n. 1
0
 public function testArrayValueCompatibility()
 {
     // These serializations where generated using revision f91f65f989cc3ffacbe924012d8f5b574e0b710c
     // The strings are the result of calling getArrayValue on the objects and then feeding this to serialize.
     $serialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:42;s:8:"altitude";N;s:9:"precision";d:0.01;s:5:"globe";s:4:"mars";}';
     $arrayForm = unserialize($serialization);
     $globeCoordinate = GlobeCoordinateValue::newFromArray($arrayForm);
     $this->assertEquals(-4.2, $globeCoordinate->getLatitude());
     $this->assertEquals(42, $globeCoordinate->getLongitude());
     $this->assertEquals(0.01, $globeCoordinate->getPrecision());
     $this->assertEquals('mars', $globeCoordinate->getGlobe());
     $serialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:-42;s:8:"altitude";d:9001;s:9:"precision";d:1;s:5:"globe";s:33:"http://www.wikidata.org/entity/Q2";}';
     $arrayForm = unserialize($serialization);
     $globeCoordinate = GlobeCoordinateValue::newFromArray($arrayForm);
     $this->assertEquals(-4.2, $globeCoordinate->getLatitude());
     $this->assertEquals(-42, $globeCoordinate->getLongitude());
     $this->assertEquals(1, $globeCoordinate->getPrecision());
     $this->assertEquals('http://www.wikidata.org/entity/Q2', $globeCoordinate->getGlobe());
 }