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

Commit

Permalink
added Country ISO 3166-1 alpha-3 code
Browse files Browse the repository at this point in the history
  • Loading branch information
gido committed Sep 8, 2014
1 parent 4c3e635 commit 984bd97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Faker/Provider/Miscellaneous.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Miscellaneous extends \Faker\Provider\Base

protected static $countryCode = array('CA', 'CN', 'DE', 'ES', 'FR', 'IE', 'IN', 'IT', 'MX', 'PT', 'RU', 'GB', 'US');

protected static $countryISOAlpha3 = array('CAN', 'CHN', 'DEU', 'ESP', 'FRA', 'IRL', 'IND', 'ITA', 'MEX', 'PRT', 'RUS', 'GBR', 'USA');

protected static $localeData = array(
'aa_DJ', 'aa_ER', 'aa_ET',
'af_NA', 'af_ZA', 'ak_GH',
Expand Down Expand Up @@ -142,6 +144,14 @@ public static function countryCode()
return static::randomElement(static::$countryCode);
}

/**
* @example 'FRA'
*/
public static function countryISOAlpha3()
{
return static::randomElement(static::$countryISOAlpha3);
}

/**
* @example 'fr'
*/
Expand Down
5 changes: 5 additions & 0 deletions test/Faker/Provider/MiscellaneousTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public function testCountryCode()
$this->assertRegExp('/^[A-Z]{2}$/', Miscellaneous::countryCode());
}

public function testCountryISOAlpha3()
{
$this->assertRegExp('/^[A-Z]{3}$/', Miscellaneous::countryISOAlpha3());
}

public function testLanguage()
{
$this->assertRegExp('/^[a-z]{2}$/', Miscellaneous::languageCode());
Expand Down

0 comments on commit 984bd97

Please sign in to comment.