public function testNormalisePostCode() { $original = '1AA 2BB'; $expected = strtolower(str_replace(' ', '', $original)); $this->assertEmpty($this->instance->getPostcode()); $this->assertEmpty($this->instance->getNormalisedPostcode()); $this->assertInstanceOf(Authority::class, $this->instance->setPostcode($original)); $this->assertEquals($original, $this->instance->getPostcode()); $this->assertEquals($expected, $this->instance->getNormalisedPostcode()); }
/** * @param Authority $authority * @return Authority */ protected function loadByPostCode(Authority $authority) { $result = $this->entityManager->getRepository('TransformCore\\PHE\\LocalHealthAuthorityBundle\\Entity\\Authority')->findOneBy(array('postcode' => $authority->getPostcode())); if ($result instanceof Authority) { $result->setCountry($authority->getCountry())->setLastUpdated(new \DateTime()); $this->updateLocalHealthAuthority($authority, $result); $this->updateDistrictCouncil($authority, $result); $this->updateCounty($authority, $result); $this->updateElectoralWard($authority, $result); $this->updateParishCouncil($authority, $result); return $result; } return $authority; }
/** * @param Authority $authority * @return array<Authority> */ public function findByPostCode(Authority $authority) { return $this->findBy(array('normalisedPostcode' => $authority->getPostcode())); }