forked from overtrue/easy-sms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhoneNumberTest.php
50 lines (42 loc) · 1.31 KB
/
PhoneNumberTest.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
43
44
45
46
47
48
49
50
<?php
/*
* This file is part of the overtrue/easy-sms.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Overtrue\EasySms\Tests;
use Overtrue\EasySms\PhoneNumber;
/**
* Class PhoneNumberTest.
*
* @author overtrue <[email protected]>
*/
class PhoneNumberTest extends TestCase
{
public function testOnlyNumber()
{
$n = new PhoneNumber(18888888888);
$this->assertSame(18888888888, $n->getNumber());
$this->assertNull($n->getIDDCode());
$this->assertSame('18888888888', $n->getUniversalNumber());
$this->assertSame('18888888888', $n->getZeroPrefixedNumber());
$this->assertSame('18888888888', \strval($n));
}
public function testDiffCode()
{
$n = new PhoneNumber(18888888888, 68);
$this->assertSame(68, $n->getIDDCode());
$n = new PhoneNumber(18888888888, '+68');
$this->assertSame(68, $n->getIDDCode());
$n = new PhoneNumber(18888888888, '0068');
$this->assertSame(68, $n->getIDDCode());
}
public function testJsonEncode()
{
$n = new PhoneNumber(18888888888, 68);
$this->assertSame(json_encode(['number' => $n->getUniversalNumber()]), \json_encode(['number' => $n]));
}
}