From 9092d162136aa2cc5e80d7a065731777b5ea3db2 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Thu, 16 Jul 2015 11:36:05 -0500 Subject: [PATCH] Have UuidInterface extend from JsonSerializable and cover it with a test --- src/Uuid.php | 2 +- src/UuidInterface.php | 2 +- tests/UuidTest.php | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Uuid.php b/src/Uuid.php index 49623e3..efe8110 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -35,7 +35,7 @@ use Ramsey\Uuid\Codec\CodecInterface; * @link http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html */ -class Uuid implements UuidInterface, \JsonSerializable +class Uuid implements UuidInterface { /** * When this namespace is specified, the name string is a fully-qualified domain name. diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 631b9a3..e2d2e9c 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -16,7 +16,7 @@ namespace Ramsey\Uuid; use Ramsey\Uuid\Converter\NumberConverterInterface; -interface UuidInterface +interface UuidInterface extends \JsonSerializable { /** diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 0c5d71a..4d5109b 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -1742,4 +1742,14 @@ class UuidTest extends TestCase $uuid = Uuid::uuid1(); $uuid->getInteger(); } + + /** + * @covers Ramsey\Uuid\Uuid::jsonSerialize + */ + public function testJsonSerialize() + { + $uuid = Uuid::uuid1(); + + $this->assertEquals('"' . $uuid->toString() . '"', json_encode($uuid)); + } }