Skip to content

Commit

Permalink
Merge pull request #610 from XWB/threads404
Browse files Browse the repository at this point in the history
Throw 404 if fos_comment_get_threads is called without parameters
  • Loading branch information
XWB authored Aug 24, 2017
2 parents ce7a477 + 7c9ded7 commit d6c6569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Controller/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function getThreadsActions(Request $request)
{
$ids = $request->query->get('ids');

if (null === $ids) {
throw new NotFoundHttpException('Cannot query threads without id\'s.');
}

$threads = $this->container->get('fos_comment.manager.thread')->findThreadsBy(array('id' => $ids));

$view = View::create()
Expand Down
13 changes: 13 additions & 0 deletions Tests/Functional/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public function testGetThread404()
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
}

/**
* Tests retrieval of a threads without id's.
*
* fos_comment_get_threads: GET: /comment_api/threads
*/
public function testGetThreads404()
{
$this->client->insulate(true);

$this->client->request('GET', '/comment_api/threads');
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
}

/**
* Tests creation of a new form.retrieval of a thread that doesnt exist.
*
Expand Down

0 comments on commit d6c6569

Please sign in to comment.