lithium\test\Mocker::chain()

public static method

Generate a chain class with the current rules of the mock.

Parameters

  • mixed

    $mock Mock object, namespaced static mock, namespaced function name.

Returns

object

MockerChain instance

Source

	public static function chain($mock) {
		$results = array();
		$string = is_string($mock);
		if (is_object($mock) && isset($mock->results)) {
			$results = static::mergeResults($mock->results, $mock::$staticResults);
		} elseif ($string && class_exists($mock) && isset($mock::$staticResults)) {
			$results = $mock::$staticResults;
		} elseif ($string && function_exists($mock) && isset(static::$_functionResults[$mock])) {
			$results = array($mock => static::$_functionResults[$mock]);
		}
		return new MockerChain($results);
	}