Skip to content

Commit

Permalink
Add more unit tests
Browse files Browse the repository at this point in the history
 - Missed some number types in ExampleNumberTest
 - Increase coverage for PrefixTimeZonesMap
  • Loading branch information
giggsey committed Aug 6, 2015
1 parent 319fd64 commit 9ad9a07
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/libphonenumber/Tests/core/ExampleNumbersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function testFixedLine($region)
$this->checkNumbersValidAndCorrectType(PhoneNumberType::FIXED_LINE, $fixedLineTypes, $region);
}

/**
* @dataProvider regionList
*/
public function testFixedLineOrMobile($region)
{
$numberTypes = array(PhoneNumberType::FIXED_LINE, PhoneNumberType::FIXED_LINE_OR_MOBILE);
$this->checkNumbersValidAndCorrectType(PhoneNumberType::FIXED_LINE_OR_MOBILE, $numberTypes, $region);
}

private function checkNumbersValidAndCorrectType($exampleNumberRequestedType, $possibleExpectedTypes, $regionCode)
{
$exampleNumber = $this->phoneNumberUtil->getExampleNumberForType($regionCode, $exampleNumberRequestedType);
Expand Down Expand Up @@ -138,6 +147,15 @@ public function testVoicemail($region)
$this->checkNumbersValidAndCorrectType(PhoneNumberType::VOICEMAIL, $voicemailTypes, $region);
}

/**
* @dataProvider regionList
*/
public function testPersonalNumber($region)
{
$numberTypes = array(PhoneNumberType::PERSONAL_NUMBER);
$this->checkNumbersValidAndCorrectType(PhoneNumberType::PERSONAL_NUMBER, $numberTypes, $region);
}

/**
* @dataProvider regionList
*/
Expand Down
14 changes: 14 additions & 0 deletions Tests/libphonenumber/Tests/timezone/UKTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberToTimeZonesMapper;
use libphonenumber\PhoneNumberUtil;

class UKTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
PhoneNumberUtil::resetInstance();
}

public function testGBNumber()
{
Expand All @@ -16,4 +21,13 @@ public function testGBNumber()
$timeZone = PhoneNumberToTimeZonesMapper::getInstance();
$this->assertEquals(array("Europe/London"), $timeZone->getTimeZonesForNumber($number));
}

public function testNonGeocodableNumber()
{
$number = new PhoneNumber();
$number->setCountryCode(44)->setNationalNumber(8001111);

$timeZone = PhoneNumberToTimeZonesMapper::getInstance();
$this->assertEquals(array("Europe/London"), $timeZone->getTimeZonesForNumber($number));
}
}

0 comments on commit 9ad9a07

Please sign in to comment.