diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index ccbbacb809..6e8fc3c544 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -890,7 +890,7 @@ class API_V1_adapter extends API_V1_Abstract $offsetStart = (int) ($request->get('offset_start') ? : 0); $perPage = (int) $request->get('per_page') ? : 10; - $query = (string) $request->request->get('query'); + $query = (string) $request->get('query'); $this->app['phraseanet.SE']->setOptions($options); $this->app['phraseanet.SE']->resetCache(); diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php index abd90e29cc..35911c09cd 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php @@ -924,6 +924,29 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract } } + /** + * @dataProvider provideAvailableSearchMethods + */ + public function testRecordsSearchRouteWithQuery($method) + { + $this->setToken(self::$token); + self::$DI['app']['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface'); + self::$DI['app']['phraseanet.SE']->expects($this->once()) + ->method('query') + ->with('koala', 0, 10) + ->will($this->returnValue( + $this->getMockBuilder('Alchemy\Phrasea\SearchEngine\SearchEngineResult') + ->disableOriginalConstructor() + ->getMock() + )); + $crawler = self::$DI['client']->request($method, '/api/v1/records/search/', $this->getParameters(array('query' => 'koala')), array(), array('HTTP_Accept' => $this->getAcceptMimeType())); + } + + public function provideAvailableSearchMethods() + { + return array(array('POST'), array('GET')); + } + /** * @covers \API_V1_adapter::caption_records */