From f9e2bae0e28eeef5ffa850be727051fd5e8c89f8 Mon Sep 17 00:00:00 2001 From: Christian Flach Date: Fri, 13 Mar 2020 16:48:27 +0000 Subject: [PATCH] Add test --- tests/Util/UnitTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Util/UnitTest.php b/tests/Util/UnitTest.php index 358ffdd..c03d09f 100644 --- a/tests/Util/UnitTest.php +++ b/tests/Util/UnitTest.php @@ -167,4 +167,10 @@ public function testToString() $this->assertEquals($this->unit->getFormatted(), $this->unit); } + + public function testToJSON() + { + $unit = new Unit(42.5, "°C", "hot", "2.5"); + $this->assertEquals(json_encode($unit), '{"value":42.5,"unit":"\u00b0C","description":"hot","precision":2.5}'); + } }