public function testCanCreateShortUrls($extension = null, $queryString = null, array $query = [])
{
$this->request->expects($this->once())->method('getContent')->will($this->returnValue('
{
"user": "user",
"imageIdentifier": "id",
"extension": ' . ($extension ? '"' . $extension . '"' : 'null') . ',
"query": ' . ($queryString ? '"' . $queryString . '"' : 'null') . '
}
'));
$this->request->expects($this->once())->method('getUser')->will($this->returnValue('user'));
$this->request->expects($this->once())->method('getImageIdentifier')->will($this->returnValue('id'));
$this->database->expects($this->once())->method('imageExists')->with('user', 'id')->will($this->returnValue(true));
$this->database->expects($this->once())->method('getShortUrlId')->with('user', 'id', $extension, $query)->will($this->returnValue(null));
$this->database->expects($this->once())->method('getShortUrlParams')->with($this->matchesRegularExpression('/[a-zA-Z0-9]{7}/'))->will($this->returnValue(null));
$this->database->expects($this->once())->method('insertShortUrl')->with($this->matchesRegularExpression('/[a-zA-Z0-9]{7}/'), 'user', 'id', $extension, $query);
$this->response->expects($this->once())->method('setModel')->with($this->isInstanceOf('Imbo\\Model\\ArrayModel'))->will($this->returnSelf());
$this->response->expects($this->once())->method('setStatusCode')->with(201);
$this->getNewResource()->createShortUrl($this->event);
}