Skip to content
Snippets Groups Projects
Commit 49be75b8 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Fix spell check handling of numeric terms. (#1515)

- Thanks to Katy Earl for reporting the problem and proposing a fix.
parent 6449de64
No related merge requests found
...@@ -165,7 +165,7 @@ class Spellcheck implements IteratorAggregate, Countable ...@@ -165,7 +165,7 @@ class Spellcheck implements IteratorAggregate, Countable
* *
* @return bool * @return bool
*/ */
protected function contains($term) protected function contains(string $term)
{ {
if ($this->terms->offsetExists($term)) { if ($this->terms->offsetExists($term)) {
return true; return true;
......
...@@ -53,7 +53,8 @@ class SpellcheckTest extends TestCase ...@@ -53,7 +53,8 @@ class SpellcheckTest extends TestCase
[ [
['this is a phrase', []], ['this is a phrase', []],
['foo', []], ['foo', []],
['foobar', []] ['foobar', []],
['1842', []], // test numeric handling (can cause problems)
], ],
'fake query' 'fake query'
); );
...@@ -61,13 +62,27 @@ class SpellcheckTest extends TestCase ...@@ -61,13 +62,27 @@ class SpellcheckTest extends TestCase
[ [
['is a', []], ['is a', []],
['bar', []], ['bar', []],
['foo bar', []] ['foo bar', []],
['1842', []],
['1843', []]
], ],
'fake query' 'fake query'
); );
$s1->mergeWith($s2); $s1->mergeWith($s2);
$this->assertCount(5, $s1); $this->assertCount(7, $s1);
$this->assertEquals($s2, $s1->getSecondary()); $this->assertEquals($s2, $s1->getSecondary());
$this->assertEquals(
[
'this is a phrase' => [],
'foobar' => [],
'foo' => [],
'bar' => [],
'foo bar' => [],
'1842' => [],
'1843' => [],
],
iterator_to_array($s1->getIterator())
);
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment