Skip to content

Commit

Permalink
Fix en_SG phone number generator (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
IonBazan authored Dec 2, 2020
1 parent e942d5a commit 56d115a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/Faker/Provider/en_SG/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber

public function tollFreeInternationalNumber()
{
return static::randomElement(static::$tollFreeInternationalNumber);
return static::numerify(static::randomElement(static::$tollFreeInternationalNumber));
}

public function tollFreeLineNumber()
{
return static::randomElement(static::$tollFreeLineNumber);
return static::numerify(static::randomElement(static::$tollFreeLineNumber));
}

public function premiumPhoneNumber()
{
return static::randomElement(static::$premiumPhoneNumber);
return static::numerify(static::randomElement(static::$premiumPhoneNumber));
}

public function mobileNumber()
Expand All @@ -85,14 +85,12 @@ public function voipNumber()
{
$format = static::randomElement(static::$voipNumber);

return $this->generator->parse($format);
return static::numerify($this->generator->parse($format));
}

public function internationalCodePrefix()
{
$format = static::randomElement(static::$internationalCodePrefix);

return $this->generator->parse($format);
return static::randomElement(static::$internationalCodePrefix);
}

public function zeroToEight()
Expand Down
25 changes: 25 additions & 0 deletions test/Faker/Provider/en_SG/PhoneNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,29 @@ public function testMobilePhoneNumberStartWith8Returns8zxxxxxx()
}
$this->assertMatchesRegularExpression('/^(\+65|65)?\s*8\s*[1-8]\d{2}\s*\d{4}$/', $mobileNumber);
}

public function testTollFreeInternationalNumber()
{
self::assertMatchesRegularExpression('/^800\s*\d{3}\s*\d{4}$/', $this->faker->tollFreeInternationalNumber);
}

public function testTollFreeLineNumber()
{
self::assertMatchesRegularExpression('/^1800\s*\d{3}\s*\d{4}$/', $this->faker->tollFreeLineNumber);
}

public function testPremiumPhoneNumber()
{
self::assertMatchesRegularExpression('/^1900\s*\d{3}\s*\d{4}$/', $this->faker->premiumPhoneNumber);
}

public function testFixedLineNumber()
{
self::assertMatchesRegularExpression('/^(\+65|65)?\s*6\d{3}\s*\d{4}$/', $this->faker->fixedLineNumber);
}

public function testVoipNumber()
{
self::assertMatchesRegularExpression('/^(\+65|65)?\s*3\d{3}\s*\d{4}$/', $this->faker->voipNumber);
}
}

0 comments on commit 56d115a

Please sign in to comment.