我一直在互联网上搜索如何模拟蛋糕请求。我想删除数据函数以使 $this->request->data('whatever') 在控制器中可用。但是我的测试用例出了点问题
$Jobs = $this->generate('Tasks' , array(
'components' => array(
'RequestHandler' => array('isMobile','prefers','renderAs'))
));
// Mock CakeRequest
$request = $this->getMock('CakeRequest', array('_readInput'));
$Jobs->RequestHandler->request = $request;
$Jobs->RequestHandler->request->expects($this->any())
->method('data')->with('anything')->will($this->returnValue('test'));
$result = $this->testAction('/tasks/test/',
array('method' => 'get', 'return' => 'vars'));
每当我调用$this->request->data('anything')
控制器时,它都会返回 null!
请尝试帮助我解决这个问题