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

PhoneNumberMatchTest::testIllegalArguments()   A

Complexity

Conditions 3
Paths 9

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 9
nop 0
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