public function testParseAndKeepRaw()
{
$alphaNumericNumber = new PhoneNumber();
$alphaNumericNumber->mergeFrom(self::$alphaNumericNumber);
$alphaNumericNumber->setRawInput("800 six-flags");
$alphaNumericNumber->setCountryCodeSource(CountryCodeSource::FROM_DEFAULT_COUNTRY);
$alphaNumericNumber->setPreferredDomesticCarrierCode("");
$this->assertEquals($alphaNumericNumber, $this->phoneUtil->parseAndKeepRawInput("800 six-flags", RegionCode::US));
$shorterAlphaNumber = new PhoneNumber();
$shorterAlphaNumber->setCountryCode(1)->setNationalNumber(8007493524);
$shorterAlphaNumber->setRawInput("1800 six-flag")->setCountryCodeSource(CountryCodeSource::FROM_NUMBER_WITHOUT_PLUS_SIGN)->setPreferredDomesticCarrierCode("");
$this->assertEquals($shorterAlphaNumber, $this->phoneUtil->parseAndKeepRawInput("1800 six-flag", RegionCode::US));
$shorterAlphaNumber->setRawInput("+1800 six-flag")->setCountryCodeSource(CountryCodeSource::FROM_NUMBER_WITH_PLUS_SIGN);
$this->assertEquals($shorterAlphaNumber, $this->phoneUtil->parseAndKeepRawInput("+1800 six-flag", RegionCode::NZ));
$shorterAlphaNumber->setRawInput("001800 six-flag")->setCountryCodeSource(CountryCodeSource::FROM_NUMBER_WITH_IDD);
$this->assertEquals($shorterAlphaNumber, $this->phoneUtil->parseAndKeepRawInput("001800 six-flag", RegionCode::NZ));
// Invalid region code supplied.
try {
$this->phoneUtil->parseAndKeepRawInput("123 456 7890", RegionCode::CS);
$this->fail("Deprecated region code not allowed: should fail.");
} catch (NumberParseException $e) {
// Expected this exception.
$this->assertEquals(NumberParseException::INVALID_COUNTRY_CODE, $e->getErrorType(), "Wrong error type stored in exception.");
}
$koreanNumber = new PhoneNumber();
$koreanNumber->setCountryCode(82)->setNationalNumber(22123456)->setRawInput("08122123456")->setCountryCodeSource(CountryCodeSource::FROM_DEFAULT_COUNTRY)->setPreferredDomesticCarrierCode("81");
$this->assertEquals($koreanNumber, $this->phoneUtil->parseAndKeepRawInput("08122123456", RegionCode::KR));
}