mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-16 16:17:43 +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\Decimal;
|
||||
|
||||
use function json_encode;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
class DecimalTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -226,4 +231,31 @@ class DecimalTest extends TestCase
|
||||
['-0012.a'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @dataProvider provideDecimal
|
||||
*/
|
||||
public function testSerializeUnserializeDecimal($value, string $expected): void
|
||||
{
|
||||
$decimal = new Decimal($value);
|
||||
$serializedDecimal = serialize($decimal);
|
||||
$unserializedDecimal = unserialize($serializedDecimal);
|
||||
|
||||
$this->assertSame($expected, $unserializedDecimal->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @dataProvider provideDecimal
|
||||
*/
|
||||
public function testJsonSerialize($value, string $expected): void
|
||||
{
|
||||
$decimal = new Decimal($value);
|
||||
$expectedJson = sprintf('"%s"', $expected);
|
||||
|
||||
$this->assertSame($expectedJson, json_encode($decimal));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user