Skip to content

[4.x] Test the console event paths of Application::execute() - #44

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-console-event-tests
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-console-event-tests

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Tests only. The event layer of Application::execute() had little coverage; together with the regression tests in the bug-fix PRs, this covers each ConsoleEvents path:

  • testEventsAreDispatchedInOrderForASuccessfulCommand: application.before_execute, console.before_command_execute, console.terminate, application.after_execute, and no error events;
  • testTerminateEventCanChangeTheExitCode: a TERMINATE listener sees exit code 0 and the command and changes the exit code;
  • testCommandErrorCanBeHandledByEventListener: a COMMAND_ERROR listener sees the command, the error and its code, setExitCode(0) makes the application exit with 0, TERMINATE still runs, APPLICATION_ERROR does not, and nothing is rendered;
  • testUnhandledCommandErrorReachesTheApplicationErrorEvent: an unhandled command exception goes through COMMAND_ERROR, TERMINATE and APPLICATION_ERROR (not AFTER_EXECUTE), is rendered, and its code becomes the exit code.

Covered elsewhere: enableCommand() (#31), --help with an unknown command (#33), ApplicationErrorEvent/CommandErrorEvent::setExitCode(), exit-code limits and a COMMAND_ERROR exit code reaching the process (#37); the existing tests cover disableCommand() and the unknown-command COMMAND_ERROR path.

The tests are inserted at a different place in ApplicationTest than those of the other open PRs, so they merge without conflicts.

Testing Instructions

vendor/bin/phpunit — the new tests pass on 4.x-dev as they pin the current behaviour.

Documentation Changes Required

None.

🤖 Generated with Claude Code

The order of the application and console events for a successful
command, exit code changes in TERMINATE, a COMMAND_ERROR listener
handling a command's exception, and an unhandled command exception
reaching APPLICATION_ERROR were not covered by tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Approved

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.

2 participants