| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class JsonTest extends TestCase |
||
| 16 | { |
||
| 17 | public function testEncode() |
||
| 18 | { |
||
| 19 | $array = ['foo' => 'bar']; |
||
| 20 | |||
| 21 | $this->assertEquals('{"foo":"bar"}', Json::encode($array)); |
||
| 22 | |||
| 23 | try { |
||
| 24 | Json::encode(''); |
||
| 25 | } catch (\Exception $e) { |
||
| 26 | $this->assertInstanceOf(JsonParseException::class, $e); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | public function testDecode() |
||
| 31 | { |
||
| 32 | $json = '{"foo":"bar"}'; |
||
| 33 | |||
| 34 | $this->assertEquals(['foo' => 'bar'], Json::decode($json, true)); |
||
| 35 | |||
| 36 | try { |
||
| 37 | Json::decode('{"foo":"bar"'); |
||
| 38 | } catch (\Exception $e) { |
||
| 39 | $this->assertInstanceOf(JsonParseException::class, $e); |
||
| 40 | } |
||
| 43 |