Completed
Push — master ( b323d1...9a7f71 )
by Evgenii
64:43 queued 24:45
created

PhoneFormatterTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testPhone11Digits() 0 5 1
A testPhone12Digits() 0 5 1
A testPhone12DigitsLink() 0 5 1
A testNoValidPhone() 0 5 1
A testPhone11DigitsLink() 0 5 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: floor12
5
 * Date: 07.01.2018
6
 * Time: 12:45
7
 */
8
9
namespace floor12\phone\tests;
10
11
12
use floor12\phone\PhoneFormatter;
13
use PHPUnit_Framework_TestCase;
14
15
class PhoneFormatterTest extends PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * If no valid number - just pass it though
19
     */
20
    public function testNoValidPhone()
21
    {
22
        $phone = 58465;
23
        $result = PhoneFormatter::format($phone);
24
        $this->assertEquals($phone, $result);
25
    }
26
27
    /**
28
     * Format 11 digits number
29
     */
30
    public function testPhone11Digits()
31
    {
32
        $phone = 79208498755;
33
        $result = PhoneFormatter::format($phone);
34
        $this->assertEquals("+7 (920) 849-87-55", $result);
35
    }
36
37
    /**
38
     * Create link with 11 digits number
39
     */
40
    public function testPhone11DigitsLink()
41
    {
42
        $phone = 79208498755;
43
        $result = PhoneFormatter::a($phone);
44
        $this->assertEquals("<a href=\"tel:+{$phone}\">+7 (920) 849-87-55</a>", $result);
45
    }
46
47
    /**
48
     * Format 12 digits number
49
     */
50
    public function testPhone12Digits()
51
    {
52
        $phone = 219208498755;
53
        $result = PhoneFormatter::format($phone);
54
        $this->assertEquals("+21 (920) 849-87-55", $result);
55
    }
56
57
    /**
58
     * Create link with 11 digits number
59
     */
60
    public function testPhone12DigitsLink()
61
    {
62
        $phone = 219208498755;
63
        $result = PhoneFormatter::a($phone);
64
        $this->assertEquals("<a href=\"tel:+{$phone}\">+21 (920) 849-87-55</a>", $result);
65
    }
66
67
68
}