From 6011c720a9059252502dcd3fc607b2e15bb8604d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 May 2016 21:29:20 +0200 Subject: [PATCH] [search] allow '-' in argument name --- Search/SearchProvider.php | 2 +- Tests/Search/SearchProviderTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Search/SearchProvider.php b/Search/SearchProvider.php index b6aa6178e..c974b6e98 100644 --- a/Search/SearchProvider.php +++ b/Search/SearchProvider.php @@ -82,7 +82,7 @@ class SearchProvider private function extractTerms(&$subject) { $terms = array(); - preg_match_all('/([a-z]+):([\w\-]+|\([^\(\r\n]+\))/', $subject, $matches); + preg_match_all('/([a-z\-]+):([\w\-]+|\([^\(\r\n]+\))/', $subject, $matches); foreach ($matches[2] as $key => $match) { //remove from search pattern diff --git a/Tests/Search/SearchProviderTest.php b/Tests/Search/SearchProviderTest.php index 8040fe3e4..a5205215c 100644 --- a/Tests/Search/SearchProviderTest.php +++ b/Tests/Search/SearchProviderTest.php @@ -165,6 +165,17 @@ class SearchProviderTest extends \PHPUnit_Framework_TestCase ), $terms); } + public function testArgumentNameWithTrait() + { + $terms = $this->p('date-from:2016-05-04'); + + $this->assertEquals(array( + '_domain' => null, + 'date-from' => '2016-05-04', + '_default' => '' + ), $terms); + } + /** * Test the behaviour when no domain is provided in the search pattern : * the default search should be enabled