Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #858 from Newman101/en_AU_AddressTest
Browse files Browse the repository at this point in the history
Improved en_AU provider and added related unit tests
  • Loading branch information
fzaninotto committed Mar 22, 2016
2 parents 588da2f + 604f008 commit bb09cf8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Faker/Provider/en_AU/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
48 changes: 48 additions & 0 deletions test/Faker/Provider/en_AU/AddressTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Faker\Provider\en_AU;

use Faker\Generator;
use Faker\Provider\en_AU\Address;

class AddressTest extends \PHPUnit_Framework_TestCase
{

/**
* @var Faker\Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->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);
}
}

?>

0 comments on commit bb09cf8

Please sign in to comment.