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
|
|
|
|