-
Notifications
You must be signed in to change notification settings - Fork 27
Events
At the heart of Peridot is an event system powered by Événement. We chose Événement for it's simplicity, and it is a key player in the simplicity of Peridot plugin development.
You can leverage all of Peridot's events via a peridot.php
file placed in the current working directory from where you run your tests, or by specifying a path to one using the -c
or --configuration
options from the command line.
//peridot.php
use Evenement\EventEmitterInterface;
//if peridot.php returns a function, that function will be executed.
return function(EventEmitterInterface $emitter) {
$emitter->on('test.failed', function($test) {
//do something with $test
});
};
The following is a list of all the events that Peridot uses, and the arguments that are included with them.
Fires when the Peridot application is first constructed. This event is useful for defining additional
CLI arguments and options. This is how the watcher plugin adds the --watch
option to Peridot.
Event Arguments:
- Environment $environment
- Application $application
Fires after the Peridot application is configured. Typically used to override configuration options or configure the Peridot runner instance.
Event Arguments:
- Configuration $configuration
- Application $application
Fires right before Peridot starts execution. Happens after CLI options are parsed and before specs are loaded.
Event Arguments:
- InputInterface $input
- OutputInterface $output
Fires when Peridot reporters are registered. Useful for registering additional reporters.
Event Arguments:
- InputInterface $input
- ReporterFactory $reporters
Fires right before Peridot starts loading tests. Useful for changing loading behavior.
Event Arguments:
- Command $command
- Configuration $configuration
Fires right before the Peridot application exits. Useful for cleanup and analyzing results of an entire run.
Event Arguments:
- integer $exitCode
- InputInterface $input
- OutputInterface $output
Fires right before the suite runner starts.
Event Arguments: No arguments
Fires right after the suite runner ends. Is passed the time it took to run as a float.
Event Arguments:
- float $time
Fires right before a suite definition is executed. Ideal for passing arguments to the definition function.
Event Arguments:
- Suite $suite
Fires right before a suite runs.
Event Arguments:
- Suite $suite
Fires right after a suite runs.
Event Arguments:
- Suite $suite
Peridot does not fire this, but if the event emitter fires this, it will signal the suite to stop running.
Event Arguments: No arguments
Fires when a test passes.
Event Arguments:
- Test $test
Fires when a test pends.
Event Arguments:
- Test $test
Fires when a test fails.
Event Arguments:
Fires right before a test runs.
Event Arguments:
- Test $test
Fires right after a test runs.
Event Arguments:
- Test $test
Fires when a PHP error occurs. The standard error arguments passed to a function registered via PHP's native set_error_handler
will be passed to this event.
Event Arguments:
- integer $errno
- string $errstr
- string $errfile
- string $errline