lithium\test\Unit::_runTestMethod()

protected method

Runs an individual test method, collecting results and catching exceptions along the way.

Parameters

  • string $method

    The name of the test method to run.

  • array $options

Returns

mixed

Filter

Executes filters applied to this class' run method.

Source

	protected function _runTestMethod($method, $options) {
		try {
			$this->setUp();
		} catch (Exception $e) {
			$this->_handleException($e, __LINE__ - 2);
			return $this->_results;
		}
		$params = compact('options', 'method');

		$passed = Filters::run($this, 'run', $params, function($params) {
			try {
				$method = $params['method'];
				$lineFlag = __LINE__ + 1;
				$this->{$method}();
			} catch (Exception $e) {
				$this->_handleException($e);
			}
		});

		foreach ($this->_expected as $expected) {
			$this->_result('fail', compact('method') + [
				'class' => get_class($this),
				'message' => "Expected exception matching `{$expected}` uncaught.",
				'data' => [],
				'file' => null,
				'line' => null,
				'assertion' => 'expectException'
			]);
		}
		$this->_expected = [];

		try {
			$this->tearDown();
		} catch (Exception $e) {
			$this->_handleException($e, __LINE__ - 2);
		}
		return $passed;
	}