public function testEnsureSerializeAlreadySet()
{
$listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->setMethods(['_action', '_controller'])->disableOriginalConstructor()->getMock();
$controller = $this->getMockBuilder('\\Cake\\Controller\\Controller')->setMethods(['set'])->disableOriginalConstructor()->getMock();
$controller->viewVars['_serialize'] = 'hello world';
$action = $this->getMockBuilder('\\Crud\\Action\\IndexAction')->setMethods(['config', 'viewVar'])->disableOriginalConstructor()->getMock();
$i = 0;
$listener->expects($this->at($i++))->method('_controller')->will($this->returnValue($controller));
$listener->expects($this->never())->method('_action');
$action->expects($this->never())->method('viewVar');
$controller->expects($this->never())->method('set');
$this->setReflectionClassInstance($listener);
$this->callProtectedMethod('_ensureSerialize', [], $listener);
}