public function testEnsureSerializeWithViewVarChanged()
{
$listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->setMethods(['_action', '_controller'])->disableOriginalConstructor()->getMock();
$controller = $this->getMockBuilder('\\Cake\\Controller\\Controller')->setMethods(['set'])->disableOriginalConstructor()->getMock();
$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->at($i++))->method('_action')->will($this->returnValue($action));
$action->expects($this->at(0))->method('viewVar')->will($this->returnValue('helloWorld'));
$controller->expects($this->once())->method('set')->with('_serialize', ['success', 'data' => 'helloWorld']);
$this->setReflectionClassInstance($listener);
$this->callProtectedMethod('_ensureSerialize', [], $listener);
}