-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPhoneNumbersInDNS.php
51 lines (41 loc) · 1.3 KB
/
TestPhoneNumbersInDNS.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @license BSD License
*/
require 'PhoneNumbersInDNS.php';
class TestPhoneNumbersInDNS extends PHPUnit_Framework_TestCase {
public function thingsThatShouldBeNullData() {
return array(
array('ouhteueu'), // random rubbish
array('v=spf1 a mx'), // a spf record
array('v=phone1'), // phone1 with no numbers
array('v=phone1 44'), // phone1 with no numbers
array('v=phone1 ee'), // phone1 with no numbers
array('v=phone1 ee 800345455'), // phone1 with no numbers
array('v=phone1 44 80uu0345455'), // phone1 with no numbers,
array('v=phone2'), // the future doesn't exist yet
);
}
/**
* @dataProvider thingsThatShouldBeNullData()
*/
public function testThingsThatShouldBeNull($txt) {
$this->assertNull(getPhoneNumberFromDNSTextString($txt));
}
public function thingsData() {
return array(
array('v=phone1 44 3700100222 BBC Scotland','44','3700100222','BBC Scotland'),
array('v=phone1 44 3700100222 ','44','3700100222','3700100222'),
);
}
/**
* @dataProvider thingsData()
*/
public function testThings($txt, $country, $number, $name) {
$o = getPhoneNumberFromDNSTextString($txt);
$this->assertFalse(is_null($o));
$this->assertEquals($country, $o['country']);
$this->assertEquals($number, $o['number']);
$this->assertEquals($name, $o['name']);
}
}