function testBuildFromJSON() { $this->CI->load->library('json'); $this->CI->load->model('mark'); $mark = new Mark(); $mark->buildFromJSON($this->_jsonTest); $this->assertEqual('FirstTest', $mark->get('classification'), 'Classification extracted from JSON'); $data = $mark->get('markData'); $this->assertEqual('Test general com', $data->generalComment, 'Ensure json process transparent'); try { $mark = new Mark(); $mark->buildFromJSON('{}xxx'); } catch (Exception $e) { $this->pass("Detected invalid JSON"); $passed = true; } if (!$passed) { $this->fail("Failed to detect invalid JSON"); } }