preserveWhiteSpace = false; $doc->loadHTML( '' . $html, LIBXML_NOERROR ); return $doc; } /** * Get parsed JSON from path * * @param string $relativePath * @return array */ protected static function getJson( string $relativePath ) : array { $json = json_decode( // TODO: Move cases out of /qunit file_get_contents( __DIR__ . '/../qunit/' . $relativePath ), true ); return $json; } /** * Get HTML from path * * @param string $relativePath * @return string */ protected static function getHtml( string $relativePath ) : string { // TODO: Move cases out of /qunit $html = file_get_contents( __DIR__ . '/../qunit/' . $relativePath ); // Remove all but the body tags from full Parsoid docs if ( strpos( $html, ']*>(.*)`s', $html, $match ); $html = "
$match[1]
"; } return $html; } /** * Create a comment pareser * * @param array $data * @return CommentParser */ protected static function createParser( array $data ) : CommentParser { $services = MediaWikiServices::getInstance(); return new CommentParser( $services->getContentLanguage(), $services->getMainConfig(), $data ); } /** * Setup the MW environment * * @param array $config * @param array $data */ protected function setupEnv( array $config, array $data ) : void { $this->setMwGlobals( $config ); $this->setMwGlobals( [ 'wgArticlePath' => $config['wgArticlePath'], 'wgNamespaceAliases' => $config['wgNamespaceIds'], // TODO: Move this to $config 'wgLocaltimezone' => $data['localTimezone'] ] ); $this->setUserLang( $config['wgContentLang'] ); $this->setContentLang( $config['wgContentLang'] ); } }