From fb6a9737514a1231ff92e3796a43708de39ad81e Mon Sep 17 00:00:00 2001 From: Thomas Bordinat Date: Sat, 17 Dec 2016 11:33:07 +0100 Subject: [PATCH] Run some tests on the NIR generator --- test/Faker/Provider/fr_FR/PersonTest.php | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/Faker/Provider/fr_FR/PersonTest.php diff --git a/test/Faker/Provider/fr_FR/PersonTest.php b/test/Faker/Provider/fr_FR/PersonTest.php new file mode 100644 index 0000000000..e231e550c1 --- /dev/null +++ b/test/Faker/Provider/fr_FR/PersonTest.php @@ -0,0 +1,36 @@ +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 testNIRReturnsTheRightLength() + { + $nir = $this->faker->nir; + $this->assertRegExp("/^[12]\d{5}[0-9A-B]\d{8}$/", $nir); + } + + public function testNIRFormattedReturnsTheRightLength() + { + $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); + } +}