From 8dcc6528596fbdc350f0afb2ebcb8f25cce96455 Mon Sep 17 00:00:00 2001 From: Hugo Fonseca Date: Wed, 23 Apr 2014 22:39:05 +0100 Subject: [PATCH 1/2] added address for pt_PT and fixed name for pt_PT --- src/Faker/Provider/pt_PT/Address.php | 121 ++++++++++++++++++++++ src/Faker/Provider/pt_PT/Person.php | 26 +++++ test/Faker/Provider/pt_PT/AddressTest.php | 30 ++++++ 3 files changed, 177 insertions(+) create mode 100644 src/Faker/Provider/pt_PT/Address.php create mode 100644 test/Faker/Provider/pt_PT/AddressTest.php diff --git a/src/Faker/Provider/pt_PT/Address.php b/src/Faker/Provider/pt_PT/Address.php new file mode 100644 index 00000000..c145a77a --- /dev/null +++ b/src/Faker/Provider/pt_PT/Address.php @@ -0,0 +1,121 @@ +addProvider(new Address($faker)); + $this->faker = $faker; + } + + public function testPostCodeIsValid() + { + $main = '[1-9]{1}[0-9]{2}[0,1,4,5,9]{1}'; + $pattern = "/^($main)|($main-[0-9]{3})+$/"; + $postcode = $this->faker->postcode(); + $this->assertSame(preg_match($pattern, $postcode), 1, $postcode); + } +} From d0d712a0d6e1c42fecb07bac09b8fb4af331f3b0 Mon Sep 17 00:00:00 2001 From: Hugo Fonseca Date: Thu, 24 Apr 2014 11:08:35 +0100 Subject: [PATCH 2/2] added links to pt_PT adress --- src/Faker/Provider/pt_PT/Address.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Faker/Provider/pt_PT/Address.php b/src/Faker/Provider/pt_PT/Address.php index c145a77a..8e3dca9b 100644 --- a/src/Faker/Provider/pt_PT/Address.php +++ b/src/Faker/Provider/pt_PT/Address.php @@ -20,10 +20,12 @@ class Address extends \Faker\Provider\Address '{{streetName}}, {{buildingNumber}}, {{secondaryAddress}}', ); + /** @link http://www.univ-ab.pt/PINTAC/carta_normas.htm address example in letters **/ protected static $addressFormats = array( "{{streetAddress}}\n{{postcode}} {{city}}", ); + /** @link http://www.mapadeportugal.net/indicecidades.asp **/ private static $cities = array( 'Abrantes', 'Agualva-Cacém', 'Águeda', 'Albufeira', 'Alcácer do Sal', 'Alcobaça', 'Almada', 'Almeirim', 'Alverca do Ribatejo', 'Amadora', 'Amarante', 'Amora', 'Anadia', 'Angra do Heroísmo', 'Aveiro', 'Barcelos', 'Barreiro', 'Beja', 'Braga', 'Bragança', 'Caldas da Rainha', 'Camara de Lobos', 'Cantanhede', 'Cartaxo', 'Castelo Branco', 'Chaves', 'Coimbra', 'Covilhã', 'Elvas', 'Entroncamento', 'Ermesinde', 'Esmoriz', 'Espinho', 'Esposende', 'Estarreja', @@ -59,7 +61,8 @@ class Address extends \Faker\Provider\Address { return static::numerify(static::randomElement(static::$secondaryAddressFormats)); } - + + /** @link http://www.indexmundi.com/pt/ **/ protected static $country = array( 'Afeganistão', 'África do Sul', 'Albânia', 'Alemanha', 'Andorra', 'Angola', 'Antigua e Barbuda', 'Arabia Saudita', 'Argélia',