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

testResponseWithExceptionConfig() public method

Test response method with exception config
    public function testResponseWithExceptionConfig()
    {
        $action = $this->getMockBuilder('\\Crud\\Action\\IndexAction')->disableOriginalConstructor()->setMethods(['config'])->getMock();
        $subject = $this->getMockBuilder('\\Crud\\Event\\Subject')->getMock();
        $subject->success = true;
        $event = new \Cake\Event\Event('Crud.afterSave', $subject);
        $i = 0;
        $listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->disableOriginalConstructor()->setMethods(['_action', 'render', '_exceptionResponse'])->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(['exception' => 'SomethingExceptional']));
        $listener->expects($this->next($listener))->method('_exceptionResponse')->with($event, 'SomethingExceptional');
        $listener->expects($this->never())->method('render');
        $listener->respond($event);
    }