PhoneNumberTest.php 729 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Generator;
  4. use Faker\Calculator\Luhn;
  5. use Faker\Provider\PhoneNumber;
  6. use PHPUnit\Framework\TestCase;
  7. class PhoneNumberTest extends TestCase
  8. {
  9. /**
  10. * @var Generator
  11. */
  12. private $faker;
  13. public function setUp()
  14. {
  15. $faker = new Generator();
  16. $faker->addProvider(new PhoneNumber($faker));
  17. $this->faker = $faker;
  18. }
  19. public function testPhoneNumberFormat()
  20. {
  21. $number = $this->faker->e164PhoneNumber();
  22. $this->assertRegExp('/^\+[0-9]{11,}$/', $number);
  23. }
  24. public function testImeiReturnsValidNumber()
  25. {
  26. $imei = $this->faker->imei();
  27. $this->assertTrue(Luhn::isValid($imei));
  28. }
  29. }