-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCPFDocumentTest.php
42 lines (34 loc) · 1.31 KB
/
CPFDocumentTest.php
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
34
35
36
37
38
39
40
41
42
<?php
it('should generate a sanitized CPF')
->group('cpf', 'generation')
->expect(fn () => cpf()->generate())->toMatch('/^[0-9]{11}$/i');
it('should generate a formatted CPF')
->group('cpf', 'generation')
->expect(fn () => cpf()->generate(true))
->toMatch('/^[0-9]{3}(\.?[0-9]{3}){2}\-?[0-9]{2}$/i');
it('should sanitize a given CPF')
->group('cpf', 'sanitization')
->expect(fn () => cpf()->sanitize('123.456.789-10'))
->toBe('12345678910');
it('should format a given CPF')
->group('cpf', 'formatting')
->expect(fn () => cpf()->format('12345678910'))
->toBe('123.456.789-10');
it('should invalidate a wrong sanitized CPF')
->group('cpf', 'validation')
->expect(fn () => cpf()->validate('65789602111'))
->toBeFalse();
it('should validate a properly sanitized CPF')
->group('cpf', 'validation')
->tap(fn () => $this->cpf = cpf()->generate())
->expect(fn () => cpf()->validate($this->cpf))
->toBeTrue();
it('should invalidate a wrong formatted CPF')
->group('cpf', 'validation')
->expect(fn () => cpf()->validate('657.896.021-11'))
->toBeFalse();
it('should validate a right formatted CPF')
->group('cpf', 'validation')
->tap(fn () => $this->cpf = cpf()->generate(true))
->expect(fn () => cpf()->validate($this->cpf))
->toBeTrue();