From e5000663996af52185fdb35f19d9e040c5904971 Mon Sep 17 00:00:00 2001 From: Juha Remes Date: Tue, 22 Mar 2016 11:23:45 +0000 Subject: [PATCH 1/4] Improved en_AU provider and added related unit tests --- src/Faker/Provider/en_AU/Address.php | 27 +++++++++++++ test/Faker/Provider/en_AU/AddressTest.php | 48 +++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 test/Faker/Provider/en_AU/AddressTest.php diff --git a/src/Faker/Provider/en_AU/Address.php b/src/Faker/Provider/en_AU/Address.php index e5077fa4f1..0458110d86 100644 --- a/src/Faker/Provider/en_AU/Address.php +++ b/src/Faker/Provider/en_AU/Address.php @@ -80,4 +80,31 @@ public static function buildingLetter() { return static::toUpper(static::randomElement(static::$buildingLetters)); } + + /** + * Returns a sane city prefix + * @example West + */ + public static function cityPrefix() + { + return static::randomElement(static::$cityPrefix); + } + + /** + * Returns a sane street suffix + * @example Beach + */ + public static function streetSuffix() + { + return static::randomElement(static::$streetSuffix); + } + + /** + * Returns a sane state + * @example New South Wales + */ + public static function state() + { + return static::randomElement(static::$state); + } } diff --git a/test/Faker/Provider/en_AU/AddressTest.php b/test/Faker/Provider/en_AU/AddressTest.php new file mode 100644 index 0000000000..ef8e9f2ef9 --- /dev/null +++ b/test/Faker/Provider/en_AU/AddressTest.php @@ -0,0 +1,48 @@ +addProvider(new Address($faker)); + $this->faker = $faker; + } + + public function testCityPrefix() + { + $cityPrefix = $this->faker->cityPrefix(); + $this->assertNotEmpty($cityPrefix); + $this->assertInternalType('string', $cityPrefix); + $this->assertRegExp('/[A-Z][a-z]+/', $cityPrefix); + } + + public function testStreetSuffix() + { + $streetSuffix = $this->faker->streetSuffix(); + $this->assertNotEmpty($streetSuffix); + $this->assertInternalType('string', $streetSuffix); + $this->assertRegExp('/[A-Z][a-z]+/', $streetSuffix); + } + + public function testState() + { + $state = $this->faker->state(); + $this->assertNotEmpty($state); + $this->assertInternalType('string', $state); + $this->assertRegExp('/[A-Z][a-z]+/', $state); + } +} + +?> From af325cb61ef6c3c3d35f4a923d3576bd38fe9159 Mon Sep 17 00:00:00 2001 From: Juha Remes Date: Tue, 22 Mar 2016 11:31:19 +0000 Subject: [PATCH 2/4] Fixed intendation errors --- src/Faker/Provider/en_AU/Address.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Faker/Provider/en_AU/Address.php b/src/Faker/Provider/en_AU/Address.php index 0458110d86..0d58868f8c 100644 --- a/src/Faker/Provider/en_AU/Address.php +++ b/src/Faker/Provider/en_AU/Address.php @@ -87,7 +87,7 @@ public static function buildingLetter() */ public static function cityPrefix() { - return static::randomElement(static::$cityPrefix); + return static::randomElement(static::$cityPrefix); } /** @@ -96,7 +96,7 @@ public static function cityPrefix() */ public static function streetSuffix() { - return static::randomElement(static::$streetSuffix); + return static::randomElement(static::$streetSuffix); } /** From 08a4a3505cbfc277e9f044ef472b06d7c6e0f8f8 Mon Sep 17 00:00:00 2001 From: Juha Remes Date: Tue, 22 Mar 2016 11:38:02 +0000 Subject: [PATCH 3/4] Made intendations consistent --- src/Faker/Provider/en_AU/Address.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Faker/Provider/en_AU/Address.php b/src/Faker/Provider/en_AU/Address.php index 0d58868f8c..237e5dcd5a 100644 --- a/src/Faker/Provider/en_AU/Address.php +++ b/src/Faker/Provider/en_AU/Address.php @@ -78,7 +78,7 @@ class Address extends \Faker\Provider\en_US\Address */ public static function buildingLetter() { - return static::toUpper(static::randomElement(static::$buildingLetters)); + return static::toUpper(static::randomElement(static::$buildingLetters)); } /** @@ -87,7 +87,7 @@ public static function buildingLetter() */ public static function cityPrefix() { - return static::randomElement(static::$cityPrefix); + return static::randomElement(static::$cityPrefix); } /** @@ -96,7 +96,7 @@ public static function cityPrefix() */ public static function streetSuffix() { - return static::randomElement(static::$streetSuffix); + return static::randomElement(static::$streetSuffix); } /** From 604f008e412dad8ac694d33d6bb6a8ae94618bd1 Mon Sep 17 00:00:00 2001 From: Juha Remes Date: Tue, 22 Mar 2016 11:47:46 +0000 Subject: [PATCH 4/4] Further fixes --- src/Faker/Provider/en_AU/Address.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Faker/Provider/en_AU/Address.php b/src/Faker/Provider/en_AU/Address.php index 237e5dcd5a..395162fbe9 100644 --- a/src/Faker/Provider/en_AU/Address.php +++ b/src/Faker/Provider/en_AU/Address.php @@ -78,7 +78,7 @@ class Address extends \Faker\Provider\en_US\Address */ public static function buildingLetter() { - return static::toUpper(static::randomElement(static::$buildingLetters)); + return static::toUpper(static::randomElement(static::$buildingLetters)); } /** @@ -87,7 +87,7 @@ public static function buildingLetter() */ public static function cityPrefix() { - return static::randomElement(static::$cityPrefix); + return static::randomElement(static::$cityPrefix); } /** @@ -96,7 +96,7 @@ public static function cityPrefix() */ public static function streetSuffix() { - return static::randomElement(static::$streetSuffix); + return static::randomElement(static::$streetSuffix); } /** @@ -105,6 +105,6 @@ public static function streetSuffix() */ public static function state() { - return static::randomElement(static::$state); + return static::randomElement(static::$state); } }