EventTracer

Class
implements Tracer

Collects PHPUnit events grouped by their concrete event class.

Description

This tracer MUST store every received event instance under its fully qualified class name so tests MAY later inspect which events were emitted and how many times each event type occurred during execution.

The collected events SHALL remain available in memory for the lifetime of this tracer instance. Consumers SHOULD treat the stored event collection as test-support state and SHOULD NOT rely on it for production behavior.

Tags
codeCoverageIgnore

Table of Contents

Interfaces

Properties

$events

Stores traced events grouped by their concrete event class name.

 : array<Event>, array<int, Event>>

Methods

count()

Returns the number of traced events for the given event class.

 : int
trace()

Records a PHPUnit event in the internal event registry.

 : void
Properties

$events

Private

Stores traced events grouped by their concrete event class name.

private array<Event>, array<int, Event>> $events = []

Description

Each key MUST be a fully qualified event class name and each value MUST contain the list of event instances received for that class.

Methods

count()

Public

Returns the number of traced events for the given event class.

public count(Event>  $eventClass) : int

Description

This method MUST return the exact number of stored events matching the provided fully qualified event class name. When no events were recorded for the given class, the method SHALL return 0.

Parameters
$eventClass : Event>

Description

the fully qualified PHPUnit event class name to count

Return values
int

Description

the number of recorded events for the specified class

trace()

Public

Records a PHPUnit event in the internal event registry.

public trace(Event  $event) : void

Description

This method MUST group the event by its concrete runtime class and SHALL append the received instance to the corresponding event list without discarding previously traced events of the same type.

Parameters
$event : Event

Description

the PHPUnit event instance to record