public function testExceptionResponse($apiConfig, $exceptionClass, $exceptionMessage, $exceptionCode, $validationErrors = [])
{
$listener = $this->getMockBuilder('\\Crud\\Listener\\ApiListener')->disableOriginalConstructor()->setMethods(null)->getMock();
$event = new \Cake\Event\Event('Crud.Exception', new \Crud\Event\Subject());
if (isset($apiConfig['type']) && $apiConfig['type'] === 'validate') {
$event->subject->set(['entity' => $this->getMockBuilder('\\Cake\\ORM\\Entity')->setMethods(['errors'])->getMock()]);
$event->subject->entity->expects($this->any())->method('errors')->will($this->returnValue($validationErrors));
}
$this->setExpectedException($exceptionClass, $exceptionMessage, $exceptionCode);
$this->setReflectionClassInstance($listener);
$this->callProtectedMethod('_exceptionResponse', [$event, $apiConfig], $listener);
}