菜谱项目

AddressTest.php 715B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Faker\Provider\en_GB;
  3. use Faker\Generator;
  4. class AddressTest extends \PHPUnit_Framework_TestCase
  5. {
  6. /**
  7. * @var Generator
  8. */
  9. private $faker;
  10. public function setUp()
  11. {
  12. $faker = new Generator();
  13. $faker->addProvider(new Address($faker));
  14. $this->faker = $faker;
  15. }
  16. /**
  17. *
  18. */
  19. public function testPostcode()
  20. {
  21. $postcode = $this->faker->postcode();
  22. $this->assertNotEmpty($postcode);
  23. $this->assertInternalType('string', $postcode);
  24. $this->assertRegExp('@^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2})$@i', $postcode);
  25. }
  26. }