Resource icon

Unit testing XenForo addons - tutorial

I may try bringing over the Railsy way of being able to seed programmatically

The mocking system that I've already built was based on the test framework that ships with Laravel.


There's a lot of similarities in the way that XenForo and Laravel work - particularly around the service container.

Laravel has database seeding and model factories built in - I was going to use that as the basis for any work that I did.
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v3.0.4 release

3.0.4 (2026-09-04)​

A maintenance release for the v3 line. Backported from the unreleased 4.0.0 branch, limited to helpers that exist in v3 — no new helpers, and no change to the PHP or PHPUnit requirements. If you can run PHP 8.3, prefer 4.x when it is released.

  • bugfix: fakesRegistry() failed with a fatal error — DataRegistry did not match the XenForo 2.3 method signatures, so the class could not be declared. The helper has...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v3.0.5 release

3.0.5 (2026-09-04)​


A documentation and packaging fix. No code changes to the framework itself.

  • the tests/Feature directory is now shipped, with a .gitkeep so it survives being committed. phpunit.xml declares a Feature test suite, and PHPUnit refuses to run at all when the directory is missing - it reports Test directory "..." not found and exits without running anything. Since git does not track...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v4.0.0 release

4.0.0 (2026-09-05)​


  • new makeEntity() and createEntity() helpers for building entities with given values
  • new fakesHttpByUrl() - chooses the http response by request URL rather than by call order
  • new fakesEvents() - records code events and stops them reaching listeners, with assertEventFired(), assertEventFiredTimes(), assertEventNotFired() and...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v4.0.2 release and v3.0.6 backport

4.0.2 (2026-09-10)​


  • bugfix: a faked response reached the caller with its body already read, so $response->getBody()->getContents() returned an empty string under both fakesHttp() and fakesHttpByUrl(). XenForo's XF\Http\Reader always gives Guzzle a sink - php://temp when you pass no $saveTo - and both fakes read the body to the end to write it there; Guzzle's own...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v4.3.0 new features and bugfixes + v3.0.7 backport of the mockery/mockery fix in 4.3.0

4.3.0 (2026-09-20)​


  • fix: dispatch() never ran the work a controller deferred. XenForo drains its run-once queue in XF\Mvc\Dispatcher::dispatchLoop(), and dispatch() resolves reroutes in its own loop instead - deliberately, because dispatchLoop() catches every controller exception and rolls the transaction back with it. So anything queued through \XF::runOnce() was simply dropped...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v4.3.1 - documentation update

4.3.1 (2026-09-20)​


A documentation release - nothing in src/ changed, so it cannot affect how a test runs. Two of the
entries below correct things the previous documentation stated as fact.

  • docs: spy() has never been documented. It has shipped in every release since 1.0.0 and appeared in neither README.md nor DOCS.md, so the only way to find it was to read...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v4.3.2 bugfix + v3.0.8 backport

4.3.2 (2026-09-21)​


  • fix: with $addonsToLoad set, a class extension registered on a pre-2.3 class name - XF\Service\User\Login rather than LoginService - was not applied, and XenForo's own class ran instead


3.0.8 (2026-09-21)​


Backported from 4.3.2.

  • fix: with $addonsToLoad set, a class extension registered on a pre-2.3 class name -...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v5.4.0 - major update, lots of new features

5.4.0 (2026-09-22)​


  • renderTemplate(), renderReply() and renderMacro() set the xf template parameter as XenForo does for a page, from getGlobalTemplateData(), so $xf.options, $xf.visitor and the rest are available to the template. It is rebuilt for every render, and an xf parameter the test set itself is left alone
  • a visitor a test set with...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v5.8.0 - multiple new feature releases

5.8.0 (2026-09-26)​


  • dispatch('') reaches the board index instead of returning a permanent redirect to it. The request uri carried a trailing ?, which does not match the canonical url XenForo compares it against. An empty route with input no longer gets a stray & either
  • dispatch() and callAction() put one of XenForo's own application classes in \XF::app() for the type...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v5.21.0 - lots of new features (rapid iterating based on test consumer feedback)

5.21.0 (2026-10-10)​

  • runRunnerStep() runs one step of a XenForo multi-part runner - a clean-up, merge or content-change service - to completion, for testing an add-on that contributes work to a step without running every other step as well. A step's return value is a resume offset rather than a result, so it loops until the step reports it has finished
  • the UsesDatabaseTransactions check for a transaction that did not survive...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v5.25.0 - more rapid iteration based on test consumer feedback

5.25.0 (2026-10-13)​

  • assertNoUnresolvedPhrases() reports a phrase key that ends at the prefix it was given. Every key XenForo structures for an add-on puts the add-on's own id last - an option group's title is option_group.<groupId> - so a key is often the prefix and nothing more, and those were passing silently. A dotted segment in front of the prefix is now reported as part of the key, so the failure names a key that can be...

Read the rest of this update entry...
 
Sim updated Unit testing XenForo addons - tutorial with a new update entry:

v5.28.0 - more rapid iteration based on test consumer feedback

5.28.0 (2026-10-15)​

  • assertAddOnClassExtensionsApply() asserts that every class extension an add-on registers actually applies. One that does not is silent - XenForo's own class runs, the add-on's code in the extension never executes, and a suite with no test on the extended class has nothing to go red, so it passes identically with the extension present and absent. The list comes from the database, so it works on an install with no development...

Read the rest of this update entry...
 
Back
Top Bottom