Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1185 from itigoppo/add-jp-phone-number-format
Browse files Browse the repository at this point in the history
Add PhoneNumberFormat for ja_JP.
  • Loading branch information
fzaninotto authored May 2, 2017
2 parents cc5720e + 26efeb2 commit bffdb5b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Faker/Provider/ja_JP/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

class PhoneNumber extends \Faker\Provider\PhoneNumber
{
/**
* @link http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/number_shitei.html#kotei-denwa
*/
protected static $formats = array(
'080-####-####',
'090-####-####',
'##-####-####'
'0#-####-####',
'0####-#-####',
'0###-##-####',
'0##-###-####',
'0##0-###-###',
);
}
21 changes: 21 additions & 0 deletions test/Faker/Provider/ja_JP/PhoneNumberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Faker\Test\Provider\ja_JP;

use Faker\Generator;
use Faker\Provider\ja_JP\PhoneNumber;

class PhoneNumberTest extends \PHPUnit_Framework_TestCase
{
public function testPhoneNumber()
{
$faker = new Generator();
$faker->addProvider(new PhoneNumber($faker));

for ($i = 0; $i < 10; $i++) {
$phoneNumber = $faker->phoneNumber;
$this->assertNotEmpty($phoneNumber);
$this->assertRegExp('/^0\d{1,4}-\d{1,4}-\d{3,4}$/', $phoneNumber);
}
}
}

0 comments on commit bffdb5b

Please sign in to comment.