1 | <?php |
||
7 | class Issue21Test extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | /** |
||
10 | * @var PhoneNumberUtil |
||
11 | */ |
||
12 | private $phoneUtil; |
||
13 | |||
14 | public function setUp() |
||
15 | { |
||
16 | PhoneNumberUtil::resetInstance(); |
||
17 | $this->phoneUtil = PhoneNumberUtil::getInstance(); |
||
18 | } |
||
19 | |||
20 | public function testFloatNumber() |
||
21 | { |
||
22 | $number = "0358112345678987"; |
||
23 | $phoneNumber = $this->phoneUtil->parse($number, "DE"); |
||
24 | |||
25 | $this->assertTrue($this->phoneUtil->isValidNumber($phoneNumber)); |
||
26 | |||
27 | $this->assertEquals('+49358112345678987', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::E164)); |
||
28 | $this->assertEquals('+49 3581 12345678987', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL)); |
||
29 | $this->assertEquals('03581 12345678987', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::NATIONAL)); |
||
30 | |||
31 | |||
32 | $this->assertEquals('011 49 3581 12345678987', $this->phoneUtil->formatOutOfCountryCallingNumber($phoneNumber, 'US')); |
||
33 | $this->assertEquals('00 49 3581 12345678987', $this->phoneUtil->formatOutOfCountryCallingNumber($phoneNumber, 'CH')); |
||
34 | } |
||
35 | |||
36 | public function testLongerNumber() |
||
37 | { |
||
38 | $number = "12345678901234567"; |
||
39 | $phoneNumber = $this->phoneUtil->parse($number, "DE"); |
||
40 | |||
41 | $this->assertEquals('+4912345678901234567', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::E164)); |
||
42 | $this->assertEquals('+49 12345678901234567', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL)); |
||
43 | $this->assertEquals('12345678901234567', $this->phoneUtil->format($phoneNumber, PhoneNumberFormat::NATIONAL)); |
||
44 | |||
45 | |||
46 | $this->assertEquals('011 49 12345678901234567', $this->phoneUtil->formatOutOfCountryCallingNumber($phoneNumber, 'US')); |
||
47 | $this->assertEquals('00 49 12345678901234567', $this->phoneUtil->formatOutOfCountryCallingNumber($phoneNumber, 'CH')); |
||
48 | } |
||
49 | } |
||
50 |