mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
Update TypeInterface to extend JsonSerializable and Serializable
This commit is contained in:
@@ -8,6 +8,11 @@ use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
use function json_encode;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
class IntegerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -163,4 +168,31 @@ class IntegerTest extends TestCase
|
||||
['foobar'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @dataProvider provideInteger
|
||||
*/
|
||||
public function testSerializeUnserializeInteger($value, string $expected): void
|
||||
{
|
||||
$integer = new IntegerObject($value);
|
||||
$serializedInteger = serialize($integer);
|
||||
$unserializedInteger = unserialize($serializedInteger);
|
||||
|
||||
$this->assertSame($expected, $unserializedInteger->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @dataProvider provideInteger
|
||||
*/
|
||||
public function testJsonSerialize($value, string $expected): void
|
||||
{
|
||||
$integer = new IntegerObject($value);
|
||||
$expectedJson = sprintf('"%s"', $expected);
|
||||
|
||||
$this->assertSame($expectedJson, json_encode($integer));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user