菜谱项目

PhoneNumberTest.php 763B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Faker\Test\Provider\en_NZ;
  3. use Faker\Generator;
  4. use Faker\Provider\en_NZ\PhoneNumber;
  5. class PhoneNumberTest extends \PHPUnit_Framework_TestCase
  6. {
  7. /**
  8. * @var Faker\Generator
  9. */
  10. private $faker;
  11. public function setUp()
  12. {
  13. $faker = new Generator();
  14. $faker->addProvider(new PhoneNumber($faker));
  15. $this->faker = $faker;
  16. }
  17. public function testIfPhoneNumberCanReturnData()
  18. {
  19. $number = $this->faker->phoneNumber;
  20. $this->assertNotEmpty($number);
  21. }
  22. public function phoneNumberFormat()
  23. {
  24. $number = $this->faker->phoneNumber;
  25. $this->assertRegExp('/(^\([0]\d{1}\))(\d{7}$)|(^\([0][2]\d{1}\))(\d{6,8}$)|([0][8][0][0])([\s])(\d{5,8}$)/', $number);
  26. }
  27. }
  28. ?>