Crud\Test\TestCase\Listener\ApiListenerTest::testEnsureSerializeWithoutViewVar PHP Method

testEnsureSerializeWithoutViewVar() public method

testEnsureSerializeWithoutViewVar
    public function testEnsureSerializeWithoutViewVar()
    {
        $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\\AddAction')->setMethods(['config', 'scope', '_controller'])->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));
        $controller->expects($this->once())->method('set')->with('_serialize', ['success', 'data' => '']);
        $action->expects($this->any())->method('scope')->will($this->returnValue('table'));
        $action->expects($this->any())->method('_controller')->will($this->returnValue($controller));
        $this->setReflectionClassInstance($listener);
        $this->callProtectedMethod('_ensureSerialize', [], $listener);
    }