Exemplo n.º 1
0
 /**
  * Validate a whole stack of postcodes
  */
 public function testMultiple()
 {
     if (($handle = fopen(__DIR__ . "/fixtures/postcodes.csv", "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 50, ",")) !== FALSE) {
             $postcode = new Lukaswhite\UkPostcodes\UkPostcode($data[0]);
             $this->assertTrue($postcode->isValid());
         }
         fclose($handle);
     }
 }
 /**
 	public function testGetPostTown()
 	{
 		$postcode = new Lukaswhite\UkPostcodes\UkPostcode('sw11 5ds');		
 		var_dump($postcode->getPostTown());
 
 		$postcode = new Lukaswhite\UkPostcodes\UkPostcode('m4 4at');		
 		var_dump($postcode->getPostTown());
 
 		$postcode = new Lukaswhite\UkPostcodes\UkPostcode('hd1 4sq');		
 		var_dump($postcode->getPostTown());
 	}
 	**/
 public function testFormatting()
 {
     $postcode = new Lukaswhite\UkPostcodes\UkPostcode('sw11 5ds');
     $this->assertEquals('SW11 5DS', $postcode->formatted());
     $postcode = new Lukaswhite\UkPostcodes\UkPostcode('sw115ds');
     $this->assertEquals('SW11 5DS', $postcode->formatted());
     $postcode = new Lukaswhite\UkPostcodes\UkPostcode('m45as');
     $this->assertEquals('M4 5AS', $postcode->formatted());
     $postcode = new Lukaswhite\UkPostcodes\UkPostcode('sw1a 2aa');
     $this->assertEquals('SW1A 2AA', $postcode->formatted());
 }