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

Commit

Permalink
Run some tests on the NIR generator
Browse files Browse the repository at this point in the history
  • Loading branch information
tbordinat committed Jan 21, 2017
1 parent d12e61f commit 2dcd85a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/Faker/Provider/fr_FR/PersonTest.php
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);
}
}

0 comments on commit 2dcd85a

Please sign in to comment.