public function processRequestThrowsExceptionIfRequestedActionIsNotPublic()
{
$this->actionController = new ActionController();
$this->inject($this->actionController, 'objectManager', $this->mockObjectManager);
$this->inject($this->actionController, 'controllerContext', $this->mockControllerContext);
$this->inject($this->actionController, 'arguments', new Arguments([]));
$mockRequest = $this->getMockBuilder(Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
$mockRequest->expects($this->any())->method('getControllerActionName')->will($this->returnValue('initialize'));
$mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock();
$mockReflectionService->expects($this->any())->method('isMethodPublic')->will($this->returnCallback(function ($className, $methodName) {
if ($methodName === 'initializeAction') {
return false;
} else {
return true;
}
}));
$this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($classname) use($mockReflectionService) {
if ($classname === ReflectionService::class) {
$this->returnValue($mockReflectionService);
}
return $this->createMock($classname);
}));
$mockHttpRequest = $this->getMockBuilder(Http\Request::class)->disableOriginalConstructor()->getMock();
$mockHttpRequest->expects($this->any())->method('getNegotiatedMediaType')->will($this->returnValue('*/*'));
$mockRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($mockHttpRequest));
$mockResponse = $this->createMock(Http\Response::class);
$this->actionController->processRequest($mockRequest, $mockResponse);
}