public function testIsPossibleShortNumber() { $possibleNumber = new PhoneNumber(); $possibleNumber->setCountryCode(33)->setNationalNumber(123456); $this->assertTrue($this->shortInfo->isPossibleShortNumber($possibleNumber)); $this->assertTrue($this->shortInfo->isPossibleShortNumberForRegion($this->parse(123456, RegionCode::FR), RegionCode::FR)); $impossibleNumber = new PhoneNumber(); $impossibleNumber->setCountryCode(33)->setNationalNumber(9); $this->assertFalse($this->shortInfo->isPossibleShortNumber($impossibleNumber)); // Note that GB and GG share the country calling code 44, and that this number is possible but // not valid. $gbNumber = new PhoneNumber(); $gbNumber->setCountryCode(44)->setNationalNumber(11001); $this->assertTrue($this->shortInfo->isPossibleShortNumber($gbNumber)); }
public function testCountryCallingCodeIsNotIgnored() { // +46 is the country calling code for Sweden (SE), and 40404 is a valid short number in the US. $this->assertFalse($this->shortInfo->isPossibleShortNumberForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US)); $this->assertFalse($this->shortInfo->isValidShortNumberForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US)); $this->assertEquals(ShortNumberCost::UNKNOWN_COST, $this->shortInfo->getExpectedCostForRegion($this->parse('+4640404', RegionCode::SE), RegionCode::US)); }
/** * @dataProvider shortNumberRegionList */ public function testCarrierSpecificShortNumbers($regionCode) { // Test the carrier-specific tag. $desc = $this->shortNumberInfo->getMetadataForRegion($regionCode)->getCarrierSpecific(); if ($desc->hasExampleNumber()) { $exampleNumber = $desc->getExampleNumber(); $carrierSpecificNumber = $this->phoneNumberUtil->parse($exampleNumber, $regionCode); if (!$this->shortNumberInfo->isPossibleShortNumberForRegion($carrierSpecificNumber, $regionCode) || !$this->shortNumberInfo->isCarrierSpecific($carrierSpecificNumber)) { $this->fail("Carrier-specific test failed for " . $regionCode); } } }