Merge pull request #177 from davispeixoto/173-expose-versions-alternative1

issue #173 expose versions alternative1
This commit is contained in:
Ben Ramsey
2017-08-04 09:32:09 -04:00
committed by GitHub
2 changed files with 70 additions and 0 deletions
+25
View File
@@ -95,6 +95,31 @@ class Uuid implements UuidInterface
*/
const VALID_PATTERN = '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$';
/**
* Version 1 (time-based) UUID object constant identifier
*/
const UUID_TYPE_TIME = 1;
/**
* Version 2 (identifier-based) UUID object constant identifier
*/
const UUID_TYPE_IDENTIFIER = 2;
/**
* Version 3 (name-based and hashed with MD5) UUID object constant identifier
*/
const UUID_TYPE_HASH_MD5 = 3;
/**
* Version 4 (random) UUID object constant identifier
*/
const UUID_TYPE_RANDOM = 4;
/**
* Version 5 (name-based and hashed with SHA1) UUID object constant identifier
*/
const UUID_TYPE_HASH_SHA1 = 5;
/**
* The factory to use when creating UUIDs.
* @var UuidFactoryInterface
+45
View File
@@ -1968,4 +1968,49 @@ class UuidTest extends TestCase
$this->assertEquals('b6c54489-38a0-5f50-a60a-fd8d76219cae', $uuid->toString());
}
/**
* @depends testGetVersionForVersion1
*/
public function testUuidVersionConstantForVersion1()
{
$uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21-0800200c9a66');
$this->assertEquals($uuid->getVersion(), Uuid::UUID_TYPE_TIME);
}
/**
* @depends testGetVersionForVersion2
*/
public function testUuidVersionConstantForVersion2()
{
$uuid = Uuid::fromString('6fa459ea-ee8a-2ca4-894e-db77e160355e');
$this->assertEquals($uuid->getVersion(), Uuid::UUID_TYPE_IDENTIFIER);
}
/**
* @depends testGetVersionForVersion3
*/
public function testUuidVersionConstantForVersion3()
{
$uuid = Uuid::fromString('6fa459ea-ee8a-3ca4-894e-db77e160355e');
$this->assertEquals($uuid->getVersion(), Uuid::UUID_TYPE_HASH_MD5);
}
/**
* @depends testGetVersionForVersion4
*/
public function testUuidVersionConstantForVersion4()
{
$uuid = Uuid::fromString('6fabf0bc-603a-42f2-925b-d9f779bd0032');
$this->assertEquals($uuid->getVersion(), Uuid::UUID_TYPE_RANDOM);
}
/**
* @depends testGetVersionForVersion5
*/
public function testUuidVersionConstantForVersion5()
{
$uuid = Uuid::fromString('886313e1-3b8a-5372-9b90-0c9aee199e5d');
$this->assertEquals($uuid->getVersion(), Uuid::UUID_TYPE_HASH_SHA1);
}
}