Skip to content

Commit d6c6569

Browse files
authored
Merge pull request #610 from XWB/threads404
Throw 404 if fos_comment_get_threads is called without parameters
2 parents ce7a477 + 7c9ded7 commit d6c6569

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Controller/ThreadController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function getThreadsActions(Request $request)
8686
{
8787
$ids = $request->query->get('ids');
8888

89+
if (null === $ids) {
90+
throw new NotFoundHttpException('Cannot query threads without id\'s.');
91+
}
92+
8993
$threads = $this->container->get('fos_comment.manager.thread')->findThreadsBy(array('id' => $ids));
9094

9195
$view = View::create()

Tests/Functional/ApiTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ public function testGetThread404()
4545
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
4646
}
4747

48+
/**
49+
* Tests retrieval of a threads without id's.
50+
*
51+
* fos_comment_get_threads: GET: /comment_api/threads
52+
*/
53+
public function testGetThreads404()
54+
{
55+
$this->client->insulate(true);
56+
57+
$this->client->request('GET', '/comment_api/threads');
58+
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
59+
}
60+
4861
/**
4962
* Tests creation of a new form.retrieval of a thread that doesnt exist.
5063
*

0 commit comments

Comments
 (0)