PhoneNumberTest.php 716B

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