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

Improved en_AU provider and added related unit tests #858

Merged
merged 4 commits into from
Mar 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}

?>