PersonTest.php 824 B

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