Skip to content

Add event contract tests for emitted events #172

@avandenberghe

Description

@avandenberghe

Summary

The six avathar.recenttopicsav.* events and three paybas.recenttopics.* deprecated aliases documented in contrib/Events.md have no executable verification. Any refactor of core/recenttopics.php could silently break the public API that downstream extensions depend on.

What to test

For each emitted event (sql_pull_topics_list, sql_pull_topics_data, modify_topics_list, topictitle_remove_re, modify_topictitle, modify_tpl_ary):

  1. Event fires — the dispatcher receives a trigger_event call with the exact event name
  2. Correct variables are present — the event data contains the documented keys
  3. Modifications are picked up — a listener that modifies a variable has its changes reflected in the output after extract() (proves the API contract end-to-end)

For the three paybas.recenttopics.* aliases additionally verify:

  • They fire after their avathar.recenttopicsav.* counterpart
  • Changes made by a new-style listener are visible to the legacy listener (shared state through sequential extract())

Approach

Use a real phpbb\event\dispatcher with inline listeners registered in the test, exercising core\recenttopics directly. No need for a full database — mock the DB and inject fixture data where needed.

Why this matters

contrib/Events.md is the documented API contract. These tests are the executable version of that contract. Without them a variable rename or a moved trigger_event call breaks every downstream extension with no CI failure.

References

  • contrib/Events.md — full event documentation
  • core/recenttopics.php lines 588, 645, 705, 792, 802, 873 — event dispatch locations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions