Completed
Push — phoneNumberMatcher ( 6b28c4 )
by Joshua
18:40
created

PhoneNumberMatchTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testValueTypeSemantics() 0 15 1
A testIllegalArguments() 0 16 3
1
<?php
2
3
namespace libphonenumber\Tests\core;
4
5
use libphonenumber\PhoneNumber;
6
use libphonenumber\PhoneNumberMatch;
7
8
class PhoneNumberMatchTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testValueTypeSemantics()
11
    {
12
        $number = new PhoneNumber();
13
14
        $match1 = new PhoneNumberMatch(10, "1 800 234 45 67", $number);
15
        $match2 = new PhoneNumberMatch(10, "1 800 234 45 67", $number);
16
17
        $this->assertEquals($match1, $match2);
18
        $this->assertEquals($match1->start(), $match2->start());
19
        $this->assertEquals($match1->end(), $match2->end());
20
        $this->assertEquals($match1->number(), $match2->number());
21
        $this->assertEquals($match1->rawString(), $match2->rawString());
22
23
        $this->assertEquals("1 800 234 45 67", $match1->rawString());
24
    }
25
26
    public function testIllegalArguments()
27
    {
28
        try {
29
            new PhoneNumberMatch(-110, "1 800 234 45 67", new PhoneNumber());
30
            $this->fail();
31
        } catch (\InvalidArgumentException $e) {
32
            $this->addToAssertionCount(1);
33
        }
34
35
        try {
36
            new PhoneNumberMatch(10, null, new PhoneNumber());
37
            $this->fail();
38
        } catch (\NullPointerException $e) {
39
            $this->addToAssertionCount(1);
40
        }
41
    }
42
}
43