public function testAuthorizationFailed() { $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(false)); $this->_oauthServiceMock->expects($this->any())->method('validateAccessTokenRequest')->will($this->returnValue('fred')); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['5', '6'])); $this->_restController->dispatch($this->_requestMock); /** Ensure that response contains proper error message. */ $expectedMsg = 'Consumer is not authorized to access 5, 6'; AuthorizationException::NOT_AUTHORIZED; $this->assertTrue($this->_responseMock->isException()); $exceptionArray = $this->_responseMock->getException(); $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage()); }