JoliNotifExecutionFinishedSubscriber
Sends a desktop notification when the PHPUnit execution finishes.
Description
This subscriber MUST summarize the current PHPUnit run using the counters collected by the shared event tracer and SHALL dispatch a concise desktop notification through the configured notifier implementation.
The generated notification MUST preserve the effective behavior currently expected by the application:
- successful runs SHALL report only the total number of executed tests, followed by expanded telemetry details;
- unsuccessful runs SHALL report the number of passed tests together with the relevant failure and error counters, followed by expanded telemetry details.
When process forking support is available, notification delivery SHOULD be delegated to a child process so the main PHPUnit process MAY continue shutting down without waiting for the desktop notification transport to complete.
Interfaces
Properties
Methods
Creates a new execution-finished subscriber instance.
Handles the PHPUnit execution finished event.
Builds the main notification body for the current execution result.
Builds the notification body for a test run containing failures or errors.
Calculates the number of tests that completed successfully.
Builds the notification body for a fully successful test run.
Builds the telemetry block appended to the notification body.
Builds the notification title for the current execution result.
Determines whether the current test run contains at least one failure or error.
private
NotifierInterface
$notifier
=
new DefaultNotifier()
private
EventTracer
$tracer
Creates a new execution-finished subscriber instance.
public
__construct(EventTracer
$tracer[, NotifierInterface
$notifier = new DefaultNotifier()]) : mixed
Description
The provided tracer MUST contain the event history collected during the current PHPUnit run so this subscriber can derive an accurate summary. When no notifier is explicitly provided, the default JoliNotif notifier SHALL be used.
Parameters
Description
the event tracer used to inspect recorded PHPUnit events and derive notification data
$notifier
:
NotifierInterface
=
new DefaultNotifier()
Description
the notifier responsible for dispatching the desktop notification
Handles the PHPUnit execution finished event.
public
notify(ExecutionFinished
$event) : void
Description
This method MUST build the final notification payload using the computed title, execution summary, and telemetry details. When process forking is available, the parent process SHALL return immediately after a successful fork, and the child process SHALL send the notification and terminate explicitly. When forking support is not available, or the fork attempt fails, the notification MUST still be delivered synchronously so functional behavior remains unchanged.
Parameters
$event
:
ExecutionFinished
Description
the emitted PHPUnit execution finished event
Builds the main notification body for the current execution result.
private
getBody() : string
Description
Successful executions MUST produce a minimal body containing only the total number of executed tests. Executions with failures or errors SHALL produce a body containing the number of passed tests together with the relevant failure and error counters.
Return values
Description
the formatted notification body
Builds the notification body for a test run containing failures or errors.
private
getFailedBody() : string
Description
The failed body MUST include the total number of passed tests and SHALL include failure and error counters only when those counters are greater than zero.
Return values
Description
the formatted failure body
Calculates the number of tests that completed successfully.
private
getPassedTests() : int
Description
The returned value MUST NEVER be negative, even if the collected event counters become inconsistent for any reason.
Return values
Description
the number of successfully completed tests
Builds the notification body for a fully successful test run.
private
getSuccessBody() : string
Description
The success body SHOULD remain intentionally brief because additional diagnostic detail is unnecessary when all tests pass.
Return values
Description
the formatted success body
Builds the telemetry block appended to the notification body.
private
getTelemetryBody(ExecutionFinished
$event) : string
Description
PHPUnit telemetry MUST be expanded into explicit, human-readable metrics instead of being displayed as a compact raw string. This method SHALL expose the most relevant execution data in a readable multi-line block, including runtime, memory consumption, suite progression, prepared test count, and the overall assertion status.
Parameters
$event
:
ExecutionFinished
Description
the PHPUnit execution finished event
Return values
Description
the formatted telemetry block, including its leading line breaks
Builds the notification title for the current execution result.
private
getTitle() : string
Description
Successful executions MUST produce a success-oriented title. Executions containing at least one failure or error SHALL produce a failure-oriented title.
Return values
Description
the formatted notification title
Determines whether the current test run contains at least one failure or error.
private
hasIssues() : bool
Return values
Description
true when the execution contains failures or errors; otherwise false