public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\PostcodeApiComAu.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['name'])->setMunicipality($json['state']['name'])->setLatitude($json['latitude'])->setLongitude($json['longitude']); $this->assertEquals($address->getTown(), 'Collingwood'); $this->assertEquals($address->getMunicipality(), 'Victoria'); $this->assertEquals($address->getLatitude(), '-37.8'); $this->assertEquals($address->getLongitude(), '144.9833'); }
public function testCanReadFindAddressResponse() { $json = file_get_contents(__DIR__ . '\\Pro6PP_BE.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['results'][0]['city'])->setMunicipality($json['results'][0]['municipality'])->setProvince($json['results'][0]['province'])->setLatitude($json['results'][0]['lat'])->setLongitude($json['results'][0]['lng']); $this->assertEquals($address->getTown(), 'Brussel'); $this->assertEquals($address->getMunicipality(), 'Brussel'); $this->assertEquals($address->getProvince(), 'Brussel'); $this->assertEquals($address->getLatitude(), '50.84515'); $this->assertEquals($address->getLongitude(), '4.35842'); }
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__ . '\\Pro6PP_NL.json'); $response = new Response(200, [], Stream::factory($json)); $json = json_decode($response->getBody(), true); $address = new Address(); $address->setTown($json['results'][0]['city'])->setMunicipality($json['results'][0]['municipality'])->setProvince($json['results'][0]['province'])->setLatitude($json['results'][0]['lat'])->setLongitude($json['results'][0]['lng']); $this->assertEquals($address->getTown(), 'Schiphol'); $this->assertEquals($address->getMunicipality(), 'Haarlemmermeer'); $this->assertEquals($address->getProvince(), 'Noord-Holland'); $this->assertEquals($address->getLatitude(), '52.30389'); $this->assertEquals($address->getLongitude(), '4.7479'); }
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'); }