function expectRender($arg_list) { $method = 'renderFile'; $this->Template->expects($this->exactly(count($arg_list)))->method($method); foreach ($arg_list as $i => $args) { $method_invoker = $this->Template->expects($this->at($i))->method($method); $args = is_array($args) ? $args : array($args); $args[0] = str_replace('/', DS, $args[0]); // at args[0] we must have a string, the template_path call_user_func_array(array($method_invoker, 'with'), $args); } }