public function testInvalidJson()
    {
        $content = <<<JSON_API
        {
            "data": {
                "type": "foo"
        }
JSON_API;
        $decoder = new DocumentDecoder();
        try {
            $decoder->decode($content);
            $this->fail('No exception thrown.');
        } catch (Exception $ex) {
            $this->assertInstanceOf(InvalidJsonException::class, $ex);
            /** @var InvalidJsonException $ex */
            $this->assertEquals(json_last_error(), $ex->getJsonError());
            $this->assertEquals(json_last_error_msg(), $ex->getJsonErrorMessage());
        }
    }
예제 #2
0
 /**
  * @param $content
  * @return Object\Document
  */
 protected function decode($content)
 {
     $decoder = new DocumentDecoder();
     return $decoder->decode($content);
 }