mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-25 17:59:47 +01:00
Merge pull request #297 from hugofonseca/master
added pt_pt phone number and tests
This commit is contained in:
commit
d0f6a36aca
50
src/Faker/Provider/pt_PT/PhoneNumber.php
Normal file
50
src/Faker/Provider/pt_PT/PhoneNumber.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Provider\pt_PT;
|
||||
|
||||
class PhoneNumber extends \Faker\Provider\PhoneNumber
|
||||
{
|
||||
/*
|
||||
* @link http://en.wikipedia.org/wiki/Telephone_numbers_in_Portugal
|
||||
*/
|
||||
protected static $formats = array(
|
||||
'+351 91#########',
|
||||
'+351 92#########',
|
||||
'+351 93#########',
|
||||
'+351 96#########',
|
||||
'+351 21#########',
|
||||
'+351 22#########',
|
||||
'+351 23#########',
|
||||
'+351 24#########',
|
||||
'+351 25#########',
|
||||
'+351 26#########',
|
||||
'+351 27#########',
|
||||
'+351 28#########',
|
||||
'+351 29#########',
|
||||
'91#########',
|
||||
'92#########',
|
||||
'93#########',
|
||||
'96#########',
|
||||
'21#########',
|
||||
'22#########',
|
||||
'23#########',
|
||||
'24#########',
|
||||
'25#########',
|
||||
'26#########',
|
||||
'27#########',
|
||||
'28#########',
|
||||
'29#########',
|
||||
);
|
||||
|
||||
protected static $mobileNumberPrefixes = array(
|
||||
'91#########',
|
||||
'92#########',
|
||||
'93#########',
|
||||
'96#########',
|
||||
);
|
||||
|
||||
public static function mobileNumber()
|
||||
{
|
||||
return static::numerify(static::randomElement(static::$mobileNumberPrefixes));
|
||||
}
|
||||
}
|
25
test/Faker/Provider/pt_PT/PhoneNumberTest.php
Normal file
25
test/Faker/Provider/pt_PT/PhoneNumberTest.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Test\Provider\pt_PT;
|
||||
|
||||
use Faker\Generator;
|
||||
use Faker\Provider\pt_PT\PhoneNumber;
|
||||
|
||||
class PhoneNumberTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$faker = new Generator();
|
||||
$faker->addProvider(new PhoneNumber($faker));
|
||||
$this->faker = $faker;
|
||||
}
|
||||
|
||||
public function testPhoneNumberReturnsPhoneNumberWithOrWithoutPrefix()
|
||||
{
|
||||
$this->assertRegExp('/^(9[1,2,3,6][0-9]{7})|(2[0-9]{8})|(\+351 [2][0-9]{8})|(\+351 9[1,2,3,6][0-9]{7})/', $this->faker->phoneNumber());
|
||||
}
|
||||
public function testMobileNumberReturnsMobileNumberWithOrWithoutPrefix()
|
||||
{
|
||||
$this->assertRegExp('/^(9[1,2,3,6][0-9]{7})/', $this->faker->mobileNumber());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user