菜谱项目

PhoneNumberTest.php 726B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Faker\Test\Provider\it_CH;
  3. use Faker\Generator;
  4. use Faker\Provider\it_CH\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 testPhoneNumber()
  18. {
  19. $this->assertRegExp('/^0\d{2} ?\d{3} ?\d{2} ?\d{2}|\+41 ?(\(0\))?\d{2} ?\d{3} ?\d{2} ?\d{2}$/', $this->faker->phoneNumber());
  20. }
  21. public function testMobileNumber()
  22. {
  23. $this->assertRegExp('/^07[56789] ?\d{3} ?\d{2} ?\d{2}$/', $this->faker->mobileNumber());
  24. }
  25. }