Goal
includes/KnowledgeGraph.php:479-490 — untested.
Test scenarios
ParserOutput::getExtensionData('knowledgegraphs') returns null → neither addJsConfigVars() nor addModules() are called.
ParserOutput::getExtensionData('knowledgegraphs') returns data → addJsConfigVars(['knowledgegraphs' => json_encode($data)]) is called and addModules('ext.KnowledgeGraph') is added to the output.
Mocking pattern
OutputPage mock ($this->createMock(OutputPage::class)) with expects($this->once())->method('addJsConfigVars') / addModules, ParserOutput mock for getExtensionData(). No DB/wiki context dependency, a plain unit test is possible.
Part of the "raise PHP coverage to ~70%" effort.
Goal
includes/KnowledgeGraph.php:479-490— untested.Test scenarios
ParserOutput::getExtensionData('knowledgegraphs')returnsnull→ neitheraddJsConfigVars()noraddModules()are called.ParserOutput::getExtensionData('knowledgegraphs')returns data →addJsConfigVars(['knowledgegraphs' => json_encode($data)])is called andaddModules('ext.KnowledgeGraph')is added to the output.Mocking pattern
OutputPagemock ($this->createMock(OutputPage::class)) withexpects($this->once())->method('addJsConfigVars')/addModules,ParserOutputmock forgetExtensionData(). No DB/wiki context dependency, a plain unit test is possible.Part of the "raise PHP coverage to ~70%" effort.