public function testWillRewriteIncomingUrlToConfiguredProtocol($accessToken, $url, $protocol, $correct)
{
if (!$correct) {
$this->setExpectedException('Imbo\\Exception\\RuntimeException', 'Incorrect access token', 400);
}
$event = $this->getEventMock(['authentication' => ['protocol' => $protocol]]);
$url = $url . '&accessToken=' . $accessToken;
$this->query->expects($this->any())->method('has')->with('accessToken')->will($this->returnValue(true));
$this->query->expects($this->any())->method('get')->with('accessToken')->will($this->returnValue($accessToken));
$this->request->expects($this->any())->method('getRawUri')->will($this->returnValue(urldecode($url)));
$this->request->expects($this->any())->method('getUriAsIs')->will($this->returnValue($url));
$this->accessControl->expects($this->any())->method('getPrivateKey')->will($this->returnValue('foobar'));
$this->listener->checkAccessToken($event);
}