Ejemplo n.º 1
0
 /**
  * Tests Poi::createFromXml()
  */
 public function testCreateFromXml()
 {
     $data = array('Id' => 405700, 'Type' => 1, 'Name' => 'ST-AMANDSBERG HOGEWEG', 'Street' => 'Hogeweg', 'Number' => '108', 'Zip' => '9040', 'City' => 'Sint-Amandsberg', 'X' => 106482, 'Y' => 195899, 'Longitude' => 3.7479, 'Latitude' => 51.0716);
     // build xml
     $xmlString = '<record>';
     foreach ($data as $key => $value) {
         $xmlString .= '<' . $key . '>' . $value . '</' . $key . '>';
     }
     $xmlString .= '</record>';
     $xml = simplexml_load_string($xmlString);
     $poi = Poi::createFromXML($xml);
     $this->assertEquals($data['Id'], $poi->getId());
     $this->assertEquals($data['Type'], $poi->getType());
     $this->assertEquals($data['Name'], $poi->getOffice());
     $this->assertEquals($data['Street'], $poi->getStreet());
     $this->assertEquals($data['Number'], $poi->getNr());
     $this->assertEquals($data['Zip'], $poi->getZip());
     $this->assertEquals($data['City'], $poi->getCity());
     $this->assertEquals($data['X'], $poi->getX());
     $this->assertEquals($data['Y'], $poi->getY());
     $this->assertEquals($data['Longitude'], $poi->getLongitude());
     $this->assertEquals($data['Latitude'], $poi->getLatitude());
 }
Ejemplo n.º 2
0
 /**
  * The GetServicePointDetails web service delivers the details for a bpost
  * pick up point referred to by its identifier.
  *
  * @param string $id       Requested point identifier
  * @param string $language Language, possible values: nl, fr
  * @param int    $type     Requested point type, possible values are:
  *                              1: Post Office
  *                              2: Post Point
  *                              4: bpack 24/7
  * @return Poi
  */
 public function getServicePointDetails($id, $language = 'nl', $type = 3)
 {
     $parameters = array();
     $parameters['Id'] = (string) $id;
     $parameters['Language'] = (string) $language;
     $parameters['Type'] = (int) $type;
     $xml = $this->doCall('info', $parameters);
     if (!isset($xml->Poi->Record)) {
         throw new Exception('Invalid XML-response.');
     }
     return Poi::createFromXML($xml->Poi->Record);
 }