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__ . '\\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'); }