This repository has been archived by the owner on Dec 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #997 from Ultim4T0m/nir-fr_FR-Person
Generates a random NIR number (fr_FR)
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Faker\Test\Provider\fr_FR; | ||
|
||
use Faker\Generator; | ||
use Faker\Provider\fr_FR\Person; | ||
|
||
class PersonTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
private $faker; | ||
|
||
public function setUp() | ||
{ | ||
$faker = new Generator(); | ||
$faker->addProvider(new Person($faker)); | ||
$this->faker = $faker; | ||
} | ||
|
||
public function testNIRReturnsTheRightGender() | ||
{ | ||
$nir = $this->faker->nir(\Faker\Provider\Person::GENDER_MALE); | ||
$this->assertStringStartsWith('1', $nir); | ||
} | ||
|
||
public function testNIRReturnsTheRightPattern() | ||
{ | ||
$nir = $this->faker->nir; | ||
$this->assertRegExp("/^[12]\d{5}[0-9A-B]\d{8}$/", $nir); | ||
} | ||
|
||
public function testNIRFormattedReturnsTheRightPattern() | ||
{ | ||
$nir = $this->faker->nir(null, true); | ||
$this->assertRegExp("/^[12]\s\d{2}\s\d{2}\s\d{1}[0-9A-B]\s\d{3}\s\d{3}\s\d{2}$/", $nir); | ||
} | ||
} |