Skip to content

Test infra: ControllerTestCase dispatch harness (unlocks controller coverage)#66

Merged
WebTigers merged 1 commit into
mainfrom
test/dispatch-harness
Jul 24, 2026
Merged

Test infra: ControllerTestCase dispatch harness (unlocks controller coverage)#66
WebTigers merged 1 commit into
mainfrom
test/dispatch-harness

Conversation

@WebTigers

Copy link
Copy Markdown
Owner

A minimal ZF1 dispatch harness so the default-namespace controllers (core/controllers/*, 0% covered) and module controllers can be tested without booting the whole Tiger_Application.

How it works

ControllerTestCase (extends IntegrationTestCase) configures a real front controller — core + module controller dirs, a Zend_View with the core script path + the Tiger_View_Helper prefix — then instantiates a controller and dispatches one action with view-rendering OFF. The goal is controller-action coverage (branch logic, view-var assignment, the _json body, the redirect / _forward decision), not .phtml output (view scripts aren't PHP classes and aren't in the coverage source). So it sidesteps the theme/layout/view-helper stack a full render needs, and you assert on what the action did: getBody() / echoed JSON, the redirect Location, the _forward target, or controller()->view->*.

Because it extends IntegrationTestCase, the DB + per-test transaction + login()/loginAs() + the real ACL are all there — a controller reads the auth identity and the shipped ACL exactly as in production. tearDown resets the front controller / layout / helper broker so nothing leaks across tests.

The bootstrap autoloader now also resolves default-namespace *Controller classes from core/controllers.

Proof

CoreControllerDispatchTest (5) drives it against the real controllers: ApiController (captures the echoed JSON envelope from the real /api gateway + a deterministic guest denial), AuthController (_json body + a 401 on bad credentials, the /auth/session heartbeat), and IndexController (a view-touching action dispatches cleanly with rendering off). Full combined suite stays green.

This unblocks Wave 6 covering core/controllers + the module controllers.

🤖 Generated with Claude Code

…er coverage

Covers the default-namespace controllers (core/controllers/*, 0% before) and any
module controller WITHOUT booting the whole Tiger_Application. It configures a real
front controller (core + module controller dirs, a view with the core script path +
the Tiger view-helper prefix), instantiates a controller, and dispatches ONE action
with view-rendering OFF — so the ACTION body runs (branch logic, view-var assignment,
_json body, redirect/_forward decision) without needing the theme/layout/.phtml stack
(view scripts aren't in the coverage source anyway). Assert on getBody()/echoed JSON,
the redirect Location, the _forward target, or controller()->view.

Extends IntegrationTestCase (DB + per-test transaction + login()/loginAs() + real ACL),
and resets the front controller / layout / helper broker in tearDown so nothing leaks.
The bootstrap autoloader now also resolves default-namespace *Controller classes from
core/controllers. CoreControllerDispatchTest proves it against ApiController (echoed
JSON + real gateway), AuthController (_json + 401), and IndexController.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@WebTigers
WebTigers merged commit d7e764c into main Jul 24, 2026
11 checks passed
WebTigers added a commit that referenced this pull request Jul 24, 2026
… 70.0%) (#67)

Five parallel agents on the module + controller layer, collected + verified on one DB:
~167 tests, combined suite 1617 green.

The unlock: a controller dispatch harness (ControllerTestCase, landed #66) that runs a
controller action with view-rendering off — so core/controllers (0% before) and every
module controller are now coverable. Results: core-controllers 0→87% (Api 80, Auth 79,
Error 95, Index 87, Page 98, Admin 91), cms 33→94, code 41→90, agent module 6→66-78,
system 37→59, + module controllers (profile 68, access 84, blog/media/analytics/identity/
signup/search/schedule 90-100%).

REAL BUG FIXED (a test found it): Backup_IndexController::_json(int,string,array):string
was an incompatible override of Tiger_Controller_Action::_json($data,$status) — a PHP 8.5
fatal at class load, so EVERY /backup request 500'd (the backup admin UI was broken).
Renamed the helper to _jsonBody(); replaced the characterization test with real dispatch
coverage.

Harness hardening (3 agents independently hit it): folded redirector->setExit(false) into
ControllerTestCase setUp (the redirector exits after headers → would kill the PHPUnit
process on a controller redirect).

CI floor MIN_COVERAGE 55 → 66.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@WebTigers
WebTigers deleted the test/dispatch-harness branch July 25, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant