public function testMaybeStripInternationalPrefix()
{
$internationalPrefix = "00[39]";
$numberToStrip = "0034567700-3898003";
// Note the dash is removed as part of the normalization.
$strippedNumber = "45677003898003";
$this->assertEquals(CountryCodeSource::FROM_NUMBER_WITH_IDD, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$this->assertEquals($strippedNumber, $numberToStrip, "The number supplied was not stripped of its international prefix.");
// Now the number no longer starts with an IDD prefix, so it should now report
// FROM_DEFAULT_COUNTRY.
$this->assertEquals(CountryCodeSource::FROM_DEFAULT_COUNTRY, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$numberToStrip = "00945677003898003";
$this->assertEquals(CountryCodeSource::FROM_NUMBER_WITH_IDD, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$this->assertEquals($strippedNumber, $numberToStrip, "The number supplied was not stripped of its international prefix.");
// Test it works when the international prefix is broken up by spaces.
$numberToStrip = "00 9 45677003898003";
$this->assertEquals(CountryCodeSource::FROM_NUMBER_WITH_IDD, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$this->assertEquals($strippedNumber, $numberToStrip, "The number supplied was not stripped of its international prefix.");
// Now the number no longer starts with an IDD prefix, so it should now report
// FROM_DEFAULT_COUNTRY.
$this->assertEquals(CountryCodeSource::FROM_DEFAULT_COUNTRY, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
// Test the + symbol is also recognised and stripped.
$numberToStrip = "+45677003898003";
$strippedNumber = "45677003898003";
$this->assertEquals(CountryCodeSource::FROM_NUMBER_WITH_PLUS_SIGN, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$this->assertEquals($strippedNumber, $numberToStrip, "The number supplied was not stripped of the plus symbol.");
// If the number afterwards is a zero, we should not strip this - no country calling code begins
// with 0.
$numberToStrip = "0090112-3123";
$strippedNumber = "00901123123";
$this->assertEquals(CountryCodeSource::FROM_DEFAULT_COUNTRY, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
$this->assertEquals($strippedNumber, $numberToStrip, "The number supplied had a 0 after the match so shouldn't be stripped.");
// Here the 0 is separated by a space from the IDD.
$numberToStrip = "009 0-112-3123";
$this->assertEquals(CountryCodeSource::FROM_DEFAULT_COUNTRY, $this->phoneUtil->maybeStripInternationalPrefixAndNormalize($numberToStrip, $internationalPrefix));
}