菜谱项目

PersonTest.php 852B

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