File: PersonTest.php

package info (click to toggle)
php-faker 1.20.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,704 kB
  • sloc: php: 115,692; xml: 213; makefile: 49
file content (33 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

namespace Faker\Test\Provider\pt_BR;

use Faker\Provider\pt_BR\Person;
use Faker\Test\TestCase;

/**
 * @group legacy
 */
final class PersonTest extends TestCase
{
    public function testCpfFormatIsValid()
    {
        $cpf = $this->faker->cpf(false);
        self::assertMatchesRegularExpression('/\d{9}\d{2}/', $cpf);
        $cpf = $this->faker->cpf(true);
        self::assertMatchesRegularExpression('/\d{3}\.\d{3}\.\d{3}-\d{2}/', $cpf);
    }

    public function testRgFormatIsValid()
    {
        $rg = $this->faker->rg(false);
        self::assertMatchesRegularExpression('/\d{8}\d/', $rg);
        $rg = $this->faker->rg(true);
        self::assertMatchesRegularExpression('/\d{2}\.\d{3}\.\d{3}-[0-9X]/', $rg);
    }

    protected function getProviders(): iterable
    {
        yield new Person($this->faker);
    }
}