File: CompanyTest.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 (80 lines) | stat: -rw-r--r-- 2,198 bytes parent folder | download
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
75
76
77
78
79
80
<?php

namespace Faker\Test\Provider\ru_RU;

use Faker\Provider\ru_RU\Company;
use Faker\Test\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

/**
 * @group legacy
 */
final class CompanyTest extends TestCase
{
    public function testINN()
    {
        self::assertMatchesRegularExpression('/^[0-9]{10}$/', $this->faker->inn10);
        self::assertEquals('77', substr($this->faker->inn10('77'), 0, 2));
        self::assertEquals('02', substr($this->faker->inn10(2), 0, 2));
    }

    public function testKPP()
    {
        self::assertMatchesRegularExpression('/^[0-9]{9}$/', $this->faker->kpp);
        self::assertEquals('01001', substr($this->faker->kpp, -5, 5));
        $inn10 = $this->faker->inn10;
        self::assertEquals(substr($inn10, 0, 4), substr($this->faker->kpp($inn10), 0, 4));
    }

    public function testCatchPhrase()
    {
        $phrase = $this->faker->catchPhrase;
        self::assertNotNull($phrase);
        self::assertGreaterThanOrEqual(
            3,
            count(explode(' ', $this->faker->catchPhrase)),
            "'$phrase' - should be contain 3 word"
        );
    }

    public static function checksumProvider()
    {
        return [
            ['143525744', '4'],
            ['500109285', '3'],
            ['500109285', '3'],
            ['500109285', '3'],
            ['027615723', '1'],
        ];
    }

    #[DataProvider('checksumProvider')]
    public function testInn10Checksum($inn10, $checksum)
    {
        self::assertSame($checksum, $this->faker->inn10Checksum($inn10), $inn10);
    }

    public static function inn10ValidatorProvider()
    {
        return [
            ['5902179757', true],
            ['5408294405', true],
            ['2724164617', true],
            ['0726000515', true],
            ['6312123552', true],
            ['1111111111', false],
            ['0123456789', false],
        ];
    }

    #[DataProvider('inn10ValidatorProvider')]
    public function testInn10IsValid($inn10, $isValid)
    {
        self::assertSame($isValid, $this->faker->inn10IsValid($inn10), $inn10);
    }

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