File: PHP7Test.php

package info (click to toggle)
php-giggsey-libphonenumber 9.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,464 kB
  • sloc: php: 484,879; sh: 107; makefile: 37
file content (51 lines) | stat: -rw-r--r-- 1,315 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
<?php

declare(strict_types=1);

namespace libphonenumber\Tests\Issues;

use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class PHP7Test extends TestCase
{
    private PhoneNumberUtil $phoneUtil;

    public function setUp(): void
    {
        PhoneNumberUtil::resetInstance();
        $this->phoneUtil = PhoneNumberUtil::getInstance();
    }

    #[DataProvider('validPolishNumbers')]
    public function testValidPolishNumbers(string $number): void
    {
        $phoneNumber = $this->phoneUtil->parse($number, 'PL');

        self::assertTrue($this->phoneUtil->isValidNumber($phoneNumber));
        self::assertSame($number, $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::NATIONAL));
    }

    /**
     * @return array<array{string}>
     */
    public static function validPolishNumbers(): array
    {
        return [
            ['22 222 22 22'],
            ['33 222 22 22'],
            ['46 222 22 22'],
            ['61 222 22 22'],
            ['62 222 22 22'],
            ['642 222 222'],
            ['65 222 22 22'],
            ['512 345 678'],
            ['800 123 456'],
            ['700 000 000'],
            ['801 234 567'],
            ['91 000 00 00'],
        ];
    }
}