public function testEnsureDataError()
{
$listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->setMethods(['_controller', '_action'])->disableOriginalConstructor()->getMock();
$controller = $this->getMockBuilder('\\Cake\\Controller\\Controller')->setMethods(['set'])->disableOriginalConstructor()->getMock();
$action = $this->getMockBuilder('\\Crud\\Action\\BaseAction')->setMethods(['config'])->disableOriginalConstructor()->getMock();
$subject = new \Crud\Event\Subject(['success' => false]);
$config = [];
$i = 0;
$listener->expects($this->at($i++))->method('_controller')->will($this->returnValue($controller));
$listener->expects($this->at($i++))->method('_action')->will($this->returnValue($action));
$action->expects($this->at(0))->method('config')->with('api.error')->will($this->returnValue($config));
$controller->expects($this->once())->method('set')->with('data', []);
$this->setReflectionClassInstance($listener);
$result = $this->callProtectedMethod('_ensureData', [$subject], $listener);
}