Skip to content
mv-steven edited this page Jul 29, 2019 · 10 revisions

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
    });
};

Event Reference

The following is a list of all the events that Peridot uses, and the arguments that are included with them.

peridot.start

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:

peridot.configure

Fires after the Peridot application is configured. Typically used to override configuration options or configure the Peridot runner instance.

Event Arguments:

peridot.execute

Fires right before Peridot starts execution. Happens after CLI options are parsed and before specs are loaded.

Event Arguments:

peridot.reporters

Fires when Peridot reporters are registered. Useful for registering additional reporters.

Event Arguments:

peridot.load

Fires right before Peridot starts loading tests. Useful for changing loading behavior.

Event Arguments:

peridot.end

Fires right before the Peridot application exits. Useful for cleanup and analyzing results of an entire run.

Event Arguments:

runner.start

Fires right before the suite runner starts.

Event Arguments: No arguments

runner.end

Fires right after the suite runner ends. Is passed the time it took to run as a float.

Event Arguments:

  • float $time

suite.define

Fires right before a suite definition is executed. Ideal for passing arguments to the definition function.

Event Arguments:

suite.start

Fires right before a suite runs.

Event Arguments:

suite.end

Fires right after a suite runs.

Event Arguments:

suite.halt

Peridot does not fire this, but if the event emitter fires this, it will signal the suite to stop running.

Event Arguments: No arguments

test.passed

Fires when a test passes.

Event Arguments:

test.pending

Fires when a test pends.

Event Arguments:

test.failed

Fires when a test fails.

Event Arguments:

test.start

Fires right before a test runs.

Event Arguments:

test.end

Fires right after a test runs.

Event Arguments:

error

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