Passed
Push — master ( 0001c9...a30983 )
by Evgenii
05:07 queued 12s
created

PhoneFormatterTest::testPhone12DigitsLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace floor12\phone\tests;
4
5
6
use floor12\phone\PhoneFormatter;
7
use PHPUnit\Framework\TestCase;
8
9
10
class PhoneFormatterTest extends TestCase
11
{
12
    /**
13
     * If no valid number - just pass it though
14
     */
15
    public function testNoValidPhone()
16
    {
17
        $phone = 58465;
18
        $result = PhoneFormatter::format($phone);
19
        $this->assertEquals($phone, $result);
20
    }
21
22
    /**
23
     * Format 11 digits number
24
     */
25
    public function testPhone11Digits()
26
    {
27
        $phone = 79208498755;
28
        $result = PhoneFormatter::format($phone);
29
        $this->assertEquals("+7 (920) 849-87-55", $result);
30
    }
31
32
    /**
33
     * Create link with 11 digits number
34
     */
35
    public function testPhone11DigitsLink()
36
    {
37
        $phone = 79208498755;
38
        $result = PhoneFormatter::a($phone);
39
        $this->assertEquals("<a href=\"tel:+{$phone}\">+7 (920) 849-87-55</a>", $result);
40
    }
41
42
    /**
43
     * Format 12 digits number
44
     */
45
    public function testPhone12Digits()
46
    {
47
        $phone = 219208498755;
48
        $result = PhoneFormatter::format($phone);
49
        $this->assertEquals("+21 (920) 849-87-55", $result);
50
    }
51
52
    /**
53
     * Create link with 11 digits number
54
     */
55
    public function testPhone12DigitsLink()
56
    {
57
        $phone = 219208498755;
58
        $result = PhoneFormatter::a($phone);
59
        $this->assertEquals("<a href=\"tel:+{$phone}\">+21 (920) 849-87-55</a>", $result);
60
    }
61
62
63
}