菜谱项目

PersonTest.php 811B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Faker\Test\Provider\pt_BR;
  3. use Faker\Generator;
  4. use Faker\Provider\pt_BR\Person;
  5. class PersonTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function setUp()
  8. {
  9. $faker = new Generator();
  10. $faker->addProvider(new Person($faker));
  11. $this->faker = $faker;
  12. }
  13. public function testCpfFormatIsValid()
  14. {
  15. $cpf = $this->faker->cpf(false);
  16. $this->assertRegExp('/\d{9}\d{2}/', $cpf);
  17. $cpf = $this->faker->cpf(true);
  18. $this->assertRegExp('/\d{3}\.\d{3}\.\d{3}-\d{2}/', $cpf);
  19. }
  20. public function testRgFormatIsValid()
  21. {
  22. $rg = $this->faker->rg(false);
  23. $this->assertRegExp('/\d{8}\d/', $rg);
  24. $rg = $this->faker->rg(true);
  25. $this->assertRegExp('/\d{2}\.\d{3}\.\d{3}-[0-9X]/', $rg);
  26. }
  27. }