菜谱项目

PhoneNumberTest.php 746B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Faker\Test\Provider\uk_UA;
  3. use Faker\Generator;
  4. use Faker\Provider\uk_UA\PhoneNumber;
  5. class PhoneNumberTest extends \PHPUnit_Framework_TestCase
  6. {
  7. /**
  8. * @var 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 testPhoneNumberFormat()
  18. {
  19. $pattern = "/((\+38)(((\(\d{3}\))\d{7}|(\(\d{4}\))\d{6})|(\d{8})))|0\d{9}/";
  20. $phoneNumber = $this->faker->phoneNumber;
  21. $this->assertSame(
  22. preg_match($pattern, $phoneNumber),
  23. 1,
  24. 'Phone number format ' . $phoneNumber . ' is wrong!'
  25. );
  26. }
  27. }