File: PersonTest.php

package info (click to toggle)
php-faker 1.20.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,412 kB
  • sloc: php: 115,671; xml: 213; makefile: 49
file content (74 lines) | stat: -rw-r--r-- 1,642 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php

namespace Faker\Test\Provider\tr_TR;

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

/**
 * @group legacy
 */
final class PersonTest extends TestCase
{
    public function testTCNo()
    {
        for ($i = 0; $i < 100; ++$i) {
            $number = $this->faker->tcNo;

            self::assertEquals(11, strlen($number));
            self::assertTrue($this->faker->tcNoisValid($number));
        }
    }

    public function tcNoChecksumProvider()
    {
        return [
            ['553006348', '82'],
            ['350630743', '78'],
            ['550600932', '88'],
            ['487932947', '70'],
            ['168113862', '40'],
        ];
    }

    /**
     * @dataProvider tcNoChecksumProvider
     *
     * @param string $tcNo
     * @param string $checksum
     */
    public function testTcNoChecksum($tcNo, $checksum)
    {
        self::assertSame($checksum, $this->faker->tcNoChecksum($tcNo), $tcNo);
    }

    public function tcNoValidatorProvider()
    {
        return [
            ['22978160678', true],
            ['26480045324', true],
            ['47278360658', true],
            ['34285002510', true],
            ['19874561012', true],

            ['11111111111', false],
            ['11234567899', false],
        ];
    }

    /**
     * @dataProvider tcNoValidatorProvider
     *
     * @param string $tcNo
     * @param bool   $isValid
     */
    public function testIsValid($tcNo, $isValid)
    {
        self::assertSame($isValid, $this->faker->tcNoisValid($tcNo), $tcNo);
    }

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