public method

Runs the test methods in this test case, with the given options.

Installs a temporary error handler that will convert regular errors to exceptions in order to make both errors and exceptions be handled in a unified way. ErrorExceptions created like this, will get the error's code as their severity. As this comes closest to their meaning.

The error handler honors the PHP error_level and will not convert errors to exceptions if they are masked by the error_level. This allows test methods to run assertions against i.e. deprecated functions. Usually the error_level is set by the test runner so that all errors are converted.


  • array $options

    The options to use when running the test. Available options are:

    • 'methods': An arbitrary array of method names to execute. If unspecified, all methods starting with 'test' are run.
    • 'reporter': A closure which gets called after each test result, which may modify the results presented.
    • 'handler': A closure which gets registered as the temporary error handler.




	public function run(array $options = array()) {
		$defaults = array(
			'methods' => $this->methods(),
			'reporter' => $this->_reporter,
			'handler' => function($code, $message, $file = null, $line = null) {
				if (error_reporting() & $code) {
					throw new ErrorException($message, 0, $code, $file, $line);
		$options += $defaults;
		$this->_results = array();
		$this->_reporter = $options['reporter'];

		try {
		} catch (Exception $e) {
			return $this->_results;

		foreach ($options['methods'] as $method) {
			if ($this->_runTestMethod($method, $options) === false) {
		return $this->_results;