Skip to content

test: tests for KnowledgeGraph::articlesInCategories() #72

Description

@gesinn-it-gea

Goal

includes/KnowledgeGraph.php:573-620 — DB query logic with a version branch (MW_VERSION >= 1.45 vs. older), currently completely untested.

Test scenarios

  • Articles in a known category are returned correctly (list of Title objects).
  • limit/offset are passed correctly to the DB query (pagination).
  • An empty category (no members) returns an empty array.
  • A category name with spaces is correctly normalized to underscores (str_replace(' ', '_', $category)).
  • Both code paths (JOIN query for MW >= 1.45, simple query for older versions) are covered, as far as the CI matrix version allows.

Mocking pattern

  • Integration test with MediaWikiIntegrationTestCase recommended: create real test pages with [[Category:...]] and query them via the method (DB access via wfGetDB, not meaningfully mockable).

Part of the "raise PHP coverage to ~70%" effort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsPHPUnit coverage work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions