菜谱项目

PhoneNumberTest.php 669B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Faker\Test\Provider\ng_NG;
  3. use Faker\Generator;
  4. use Faker\Provider\en_NG\PhoneNumber;
  5. class PhoneNumberTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function setUp()
  8. {
  9. $faker = new Generator();
  10. $faker->addProvider(new PhoneNumber($faker));
  11. $this->faker = $faker;
  12. }
  13. public function testPhoneNumberReturnsPhoneNumberWithOrWithoutCountryCode()
  14. {
  15. $phoneNumber = $this->faker->phoneNumber();
  16. $this->assertNotEmpty($phoneNumber);
  17. $this->assertInternalType('string', $phoneNumber);
  18. $this->assertRegExp('/^(0|(\+234))\s?[789][01]\d\s?(\d{3}\s?\d{4})/', $phoneNumber);
  19. }
  20. }