/** * @param Address &$address * @return bool */ protected function loadAuthorityForPostCode(Address &$address) { /** @var array<Authority> $lha */ $lha = $this->lhaService->findByPostCode(strtolower(str_replace(' ', '', $address->getPostcode()))); if (count($lha)) { $address->setCountry($lha[0]->getCountry())->setCounty($lha[0]->getCountyName())->setDistrict($lha[0]->getDistrictCouncilName()); return true; } return false; }
public function testFindByPostcode() { $expected = (new Authority())->setPostcode('AA1 BB3')->setDateCreated($this->expectedDate); $result = $this->instance->findByPostCode($expected->getPostcode()); $this->assertEquals($expected, $result); }