From 7fe04fb63f6846c6442891ccc32b43a704e9f41a Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Fri, 13 Jun 2014 16:51:39 +0200 Subject: [PATCH] dev #14379 fix autocomplete seach with simple quote --- library/Class/Autocomplete/Index.php | 9 ------ .../library/Class/Autocomplete/IndexTest.php | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/library/Class/Autocomplete/Index.php b/library/Class/Autocomplete/Index.php index 15bfb4a23d5..83e19d4467f 100644 --- a/library/Class/Autocomplete/Index.php +++ b/library/Class/Autocomplete/Index.php @@ -141,13 +141,4 @@ class Class_Autocomplete_Index { return new Class_Autocomplete_IndexSearcher(); } } - - -class Class_Autocomplete_IndexSearcher { - public function search($file_path, $terms) { - exec("grep -ri -E -m10 --no-filename '(^|\s)" . $terms . "' " . $file_path . " | sort --unique", $out); - return $out; - } -} - ?> \ No newline at end of file diff --git a/tests/library/Class/Autocomplete/IndexTest.php b/tests/library/Class/Autocomplete/IndexTest.php index c1674668eae..e9888f174fe 100644 --- a/tests/library/Class/Autocomplete/IndexTest.php +++ b/tests/library/Class/Autocomplete/IndexTest.php @@ -70,4 +70,32 @@ class Class_Autocomplete_IndexTest extends Storm_Test_ModelTestCase{ $this->_file_system->methodHasBeenCalledWithParams('fwrite', [$handle, "Bone of my bones de Charle\n"])); } } + + + +class Class_Autocomplete_IndexSearcherTest extends Storm_Test_ModelTestCase{ + public function setUp() { + parent::setUp(); + Class_Notice::beVOlatile(); + } + + + protected function searchFor($term) { + return (new Class_Autocomplete_IndexSearcher()) + ->search(ROOT_PATH.'tests/library/Class/Autocomplete/index/', $term); + } + + + /** @test */ + public function autocompleteTermShouldBeFound() { + $this->assertEquals('Jean-Pierre Cuq', $this->searchFor('jean-p')[0]); + } + + + /** @test */ + public function autocompleteTermWithSimpleQuoteShouldBeFound() { + $this->assertContains('Centre interdépartemental', $this->searchFor("d'ile")[0]); + } +} + ?> \ No newline at end of file -- GitLab