You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UuidTest.php 710B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Provider\Uuid as BaseProvider;
  4. class UuidTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testUuidReturnsUuid()
  7. {
  8. $uuid = BaseProvider::uuid();
  9. $this->assertTrue($this->isUuid($uuid));
  10. }
  11. public function testUuidExpectedSeed()
  12. {
  13. mt_srand(123);
  14. $this->assertEquals("8e2e0c84-50dd-367c-9e66-f3ab455c78d6", BaseProvider::uuid());
  15. $this->assertEquals("073eb60a-902c-30ab-93d0-a94db371f6c8", BaseProvider::uuid());
  16. }
  17. protected function isUuid($uuid)
  18. {
  19. return is_string($uuid) && (bool) preg_match('/^[a-f0-9]{8,8}-(?:[a-f0-9]{4,4}-){3,3}[a-f0-9]{12,12}$/i', $uuid);
  20. }
  21. }