mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
Serialization should not use internal codec
This commit is contained in:
@@ -20,12 +20,15 @@ use Ramsey\Uuid\Nonstandard\Fields as NonstandardFields;
|
||||
use Ramsey\Uuid\Nonstandard\UuidBuilder;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidFactory;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function hex2bin;
|
||||
use function pack;
|
||||
use function serialize;
|
||||
use function str_replace;
|
||||
use function unserialize;
|
||||
|
||||
class OrderedTimeCodecTest extends TestCase
|
||||
{
|
||||
@@ -229,4 +232,20 @@ class OrderedTimeCodecTest extends TestCase
|
||||
|
||||
$codec->decodeBytes($bytes);
|
||||
}
|
||||
|
||||
public function testSerializationDoesNotUseOrderedTimeCodec(): void
|
||||
{
|
||||
$expected = '9ec692cc-67c8-11eb-ae93-0242ac130002';
|
||||
|
||||
$codec = new OrderedTimeCodec(
|
||||
(new UuidFactory())->getUuidBuilder()
|
||||
);
|
||||
$decoded = $codec->decode($expected);
|
||||
$serialized = serialize($decoded);
|
||||
$unserializedUuid = unserialize($serialized);
|
||||
|
||||
$expectedUuid = Uuid::fromString($expected);
|
||||
$this->assertSame($expectedUuid->getVersion(), $unserializedUuid->getVersion());
|
||||
$this->assertTrue($expectedUuid->equals($unserializedUuid));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user