lithium\test\Mocker::$_mockDelegateIngredients

protected static property

A list of code to be generated for the Delegate.

The Delegate directly extends the class you wish to mock and makes all methods publically available to other classes but should not be accessed directly by any other classes other than Mock.

Source

	protected static $_mockDelegateIngredients = [
		'startClass' => [
			'namespace {:namespace};',
			'class MockDelegate extends \{:mocker} {',
			'    public $parent = null;',
		],
		'constructor' => [
			'{:modifiers} function __construct({:args}) {',
			'    $args = compact({:stringArgs});',
			'    $argCount = func_num_args();',
			'    $this->parent = $argCount === 0 ? false : func_get_arg($argCount - 1);',
			'    if (!is_a($this->parent, __NAMESPACE__ . "\Mock")) {',
			'        $class = new \ReflectionClass(\'{:namespace}\Mock\');',
			'        $this->parent = $class->newInstanceArgs($args);',
			'    }',
			'    $this->parent->mocker = $this;',
			'    if (method_exists(\'{:mocker}\', "__construct")) {',
			'        call_user_func_array("parent::__construct", $args);',
			'    }',
			'}',
		],
		'method' => [
			'{:modifiers} function {:method}({:args}) {',
			'    $args = compact({:stringArgs});',
			'    $token = spl_object_hash($this);',
			'    if (func_num_args() > 0 && func_get_arg(func_num_args() - 1) === $token) {',
			'        return call_user_func_array("parent::{:method}", compact({:stringArgs}));',
			'    }',
			'    $method = [$this->parent, "{:method}"];',
			'    return call_user_func_array($method, $args);',
			'}',
		],
		'staticMethod' => [
			'{:modifiers} function {:method}({:args}) {',
			'    $args = compact({:stringArgs});',
			'    $token = "1f3870be274f6c49b3e31a0c6728957f";',
			'    if (func_num_args() > 0 && func_get_arg(func_num_args() - 1) === $token) {',
			'        return call_user_func_array("parent::{:method}", compact({:stringArgs}));',
			'    }',
			'    $method = \'{:namespace}\Mock::{:method}\';',
			'    return call_user_func_array($method, $args);',
			'}',
		],
		'endClass' => [
			'}',
		],
	];