/** * @dataProvider provideDataAndParserText */ public function testFillParserOutput($data, $expected) { $obj = new JsonContent(FormatJson::encode($data)); $parserOutput = $obj->getParserOutput($this->getMockTitle(), null, null, true); $this->assertInstanceOf('ParserOutput', $parserOutput); $this->assertEquals($expected, $parserOutput->getText()); }
/** * @return bool: Whether content is valid JSON Schema. */ function isValid() { try { return parent::isValid() && $this->validate(); } catch (JsonSchemaException $e) { return false; } }
public function convert($toModel, $lossy = '') { if ($toModel === CONTENT_MODEL_WIKITEXT && $lossy === 'lossy') { global $wgContLang; // using wgContLang is kind of icky. Maybe we should transclude // from mediawiki namespace, or give up on not splitting the // parser cache and just use {{int:... (?) $renderOpts = $this->getFullRenderListOptions(); $text = $this->convertToWikitext($wgContLang, $renderOpts); return ContentHandler::makeContent($text, null, $toModel); } elseif ($toModel === CONTENT_MODEL_JSON) { return ContentHandler::makeContent($this->getNativeData(), null, $toModel); } return parent::convert($toModel, $lossy); }