From 2dcd85a6c5f0cd2ef4385e2b5ae581274f7b97b9 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..b5bc805623 --- /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 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); + } +}