PersonTest.php 863 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Faker\Test\Provider\fr_FR;
  3. use Faker\Generator;
  4. use Faker\Provider\fr_FR\Person;
  5. use PHPUnit\Framework\TestCase;
  6. class PersonTest extends TestCase
  7. {
  8. private $faker;
  9. public function setUp()
  10. {
  11. $faker = new Generator();
  12. $faker->addProvider(new Person($faker));
  13. $this->faker = $faker;
  14. }
  15. public function testNIRReturnsTheRightGender()
  16. {
  17. $nir = $this->faker->nir(\Faker\Provider\Person::GENDER_MALE);
  18. $this->assertStringStartsWith('1', $nir);
  19. }
  20. public function testNIRReturnsTheRightPattern()
  21. {
  22. $nir = $this->faker->nir;
  23. $this->assertRegExp("/^[12]\d{5}[0-9A-B]\d{8}$/", $nir);
  24. }
  25. public function testNIRFormattedReturnsTheRightPattern()
  26. {
  27. $nir = $this->faker->nir(null, true);
  28. $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);
  29. }
  30. }