public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\GetAddressIO.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = $response->json();
     $address = new Address();
     $address->setLatitude($json['Latitude'])->setLongitude($json['Longitude'])->setStreet($json['Addresses'][0]);
     $this->assertEquals($address->getLatitude(), '51.503038');
     $this->assertEquals($address->getLongitude(), '-0.128371');
     $this->assertEquals($address->getStreet(), 'Prime Minister & First Lord of the Treasury, 10 Downing Street, , , , London, Greater London');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\GetAddressIO.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setLatitude($json['Latitude'])->setLongitude($json['Longitude'])->setStreet($json['Addresses'][0]);
     $this->assertEquals($address->getLatitude(), '51.500571');
     $this->assertEquals($address->getLongitude(), '-0.142881');
     $this->assertEquals($address->getStreet(), 'Buckingham Palace, , , , , London, Greater London');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\IdealPostcodes.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setTown($json['result'][0]['post_town'])->setStreet($json['result'][0]['line_1'])->setLatitude($json['result'][0]['latitude'])->setLongitude($json['result'][0]['longitude']);
     $this->assertEquals($address->getTown(), 'LONDON');
     $this->assertEquals($address->getStreet(), 'Buckingham Palace');
     $this->assertEquals($address->getLatitude(), '51.50100915646');
     $this->assertEquals($address->getLongitude(), '-0.14158759787698');
 }
예제 #4
0
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\Geocodio.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setMunicipality($json['results'][0]['address_components']['state'])->setStreet($json['results'][0]['address_components']['formatted_street'])->setTown($json['results'][0]['address_components']['city'])->setLatitude($json['results'][0]['location']['lat'])->setLongitude($json['results'][0]['location']['lng']);
     $this->assertEquals($address->getMunicipality(), 'CA');
     $this->assertEquals($address->getStreet(), 'Bob Hope Dr');
     $this->assertEquals($address->getTown(), 'Rancho Mirage');
     $this->assertEquals($address->getLatitude(), '33.739464');
     $this->assertEquals($address->getLongitude(), '-116.40803');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\PostcodeData.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = $response->json();
     $address = new Address();
     $address->setStreet($json['details'][0]['street'])->setTown($json['details'][0]['city'])->setMunicipality($json['details'][0]['municipality'])->setProvince($json['details'][0]['province'])->setLatitude($json['details'][0]['lat'])->setLongitude($json['details'][0]['lon']);
     $this->assertEquals($address->getStreet(), 'Evert van de Beekstraat');
     $this->assertEquals($address->getTown(), 'Schiphol');
     $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer');
     $this->assertEquals($address->getProvince(), 'Noord-Holland');
     $this->assertEquals($address->getLatitude(), '52.3035437835548');
     $this->assertEquals($address->getLongitude(), '4.7474064734608');
 }
 public function testCanReadFindAddressResponse()
 {
     $json = file_get_contents(__DIR__ . '\\PostcodeApiNu.json');
     $response = new Response(200, [], Stream::factory($json));
     $json = json_decode($response->getBody(), true);
     $address = new Address();
     $address->setStreet($json['_embedded']['addresses'][0]['street'])->setTown($json['_embedded']['addresses'][0]['city']['label'])->setMunicipality($json['_embedded']['addresses'][0]['municipality']['label'])->setProvince($json['_embedded']['addresses'][0]['province']['label'])->setLatitude($json['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][1])->setLongitude($json['_embedded']['addresses'][0]['geo']['center']['wgs84']['coordinates'][0]);
     $this->assertEquals($address->getStreet(), 'Evert van de Beekstraat');
     $this->assertEquals($address->getTown(), 'Schiphol');
     $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer');
     $this->assertEquals($address->getProvince(), 'Noord-Holland');
     $this->assertEquals($address->getLatitude(), '52.3052531');
     $this->assertEquals($address->getLongitude(), '4.7517051');
 }