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

testResponse() public method

Test response method
public testResponse ( ) : void
return void
    public function testResponse()
    {
        $action = $this->getMockBuilder('\\Crud\\Action\\IndexAction')->disableOriginalConstructor()->setMethods(['config'])->getMock();
        $response = $this->getMockBuilder('\\Cake\\Network\\Response')->setMethods(['statusCode'])->getMock();
        $subject = $this->getMockBuilder('\\Crud\\Event\\Subject')->getMock();
        $subject->success = true;
        $event = new \Cake\Event\Event('Crud.afterSave', $subject);
        $listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->disableOriginalConstructor()->setMethods(['_action', 'render'])->getMock();
        $listener->expects($this->next($listener))->method('_action')->with()->will($this->returnValue($action));
        $action->expects($this->next($action))->method('config')->with('api.success')->will($this->returnValue(['code' => 200]));
        $listener->expects($this->next($listener))->method('render')->with($subject)->will($this->returnValue($response));
        $response->expects($this->next($response))->method('statusCode')->with(200);
        $listener->respond($event);
    }