Goal
Two hook-adjacent methods with no test coverage.
Test scenarios
onSidebarBeforeOutput() (includes/KnowledgeGraph.php:195-206)
$wgKnowledgeGraphShowSidebarLink is false/empty → early return, $sidebar remains unchanged.
$wgKnowledgeGraphShowSidebarLink is true → $sidebar['TOOLBOX'][] receives an entry with the correct text (from wfMessage('knowledgegraph-knowledgegraphdesigner-label')) and href (URL of the KnowledgeGraphDesigner special page).
ensureKnowledgeGraphOptionsPageExists() (includes/KnowledgeGraph.php:148-181, private, currently only reachable indirectly via onBeforePageDisplay())
- The page
MediaWiki:KnowledgeGraphOptions already exists → no write happens (saveRevision is not called).
- The page is missing → it is created from
data/KnowledgeGraphOptions.js (content model CONTENT_MODEL_JAVASCRIPT, author is the MediaWiki default system user).
- The template file is missing (
file_exists() returns false) → the method aborts without error (only a debug log).
Mocking pattern
Integration test (MediaWikiIntegrationTestCase) recommended, since real page creation (WikiPage::newPageUpdater) is involved. ensureKnowledgeGraphOptionsPageExists() is private — test it via the public onBeforePageDisplay() hook, or via reflection (ReflectionMethod::setAccessible).
Part of the "raise PHP coverage to ~70%" effort.
Goal
Two hook-adjacent methods with no test coverage.
Test scenarios
onSidebarBeforeOutput()(includes/KnowledgeGraph.php:195-206)$wgKnowledgeGraphShowSidebarLinkisfalse/empty → early return,$sidebarremains unchanged.$wgKnowledgeGraphShowSidebarLinkistrue→$sidebar['TOOLBOX'][]receives an entry with the correcttext(fromwfMessage('knowledgegraph-knowledgegraphdesigner-label')) andhref(URL of theKnowledgeGraphDesignerspecial page).ensureKnowledgeGraphOptionsPageExists()(includes/KnowledgeGraph.php:148-181,private, currently only reachable indirectly viaonBeforePageDisplay())MediaWiki:KnowledgeGraphOptionsalready exists → no write happens (saveRevisionis not called).data/KnowledgeGraphOptions.js(content modelCONTENT_MODEL_JAVASCRIPT, author is theMediaWiki defaultsystem user).file_exists()returnsfalse) → the method aborts without error (only a debug log).Mocking pattern
Integration test (
MediaWikiIntegrationTestCase) recommended, since real page creation (WikiPage::newPageUpdater) is involved.ensureKnowledgeGraphOptionsPageExists()isprivate— test it via the publiconBeforePageDisplay()hook, or via reflection (ReflectionMethod::setAccessible).Part of the "raise PHP coverage to ~70%" effort.