forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpellcheckTest.php
94 lines (74 loc) · 2.38 KB
/
SpellcheckTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace Solarium\Tests\Component\Result\Spellcheck;
use PHPUnit\Framework\TestCase;
use Solarium\Component\Result\Spellcheck\Collation;
use Solarium\Component\Result\Spellcheck\Result;
use Solarium\Component\Result\Spellcheck\Suggestion;
class SpellcheckTest extends TestCase
{
/**
* @var Result
*/
protected $result;
protected $suggestions;
protected $collations;
protected $correctlySpelled;
public function setUp(): void
{
$this->suggestions = [
'key1' => new Suggestion(1, 2, 3, 4, ['content1']),
'key2' => new Suggestion(1, 2, 3, 4, ['content2']),
];
$this->collations = [
new Collation('dummy1', null, []),
new Collation('dummy2', null, []),
];
$this->correctlySpelled = false;
$this->result = new Result($this->suggestions, $this->collations, $this->correctlySpelled);
}
public function testGetCollation()
{
$this->assertEquals(reset($this->collations), $this->result->getCollation());
}
public function testGetCollationWithoutData()
{
$result = new Result($this->suggestions, [], $this->correctlySpelled);
$this->assertNull($result->getCollation());
}
public function testGetCollationWithKey()
{
$this->assertEquals($this->collations[0], $this->result->getCollation(0));
}
public function testGetCollations()
{
$this->assertEquals($this->collations, $this->result->getCollations());
}
public function testGetCorrectlySpelled()
{
$this->assertEquals($this->correctlySpelled, $this->result->getCorrectlySpelled());
}
public function testGetSuggestion()
{
$this->assertEquals($this->suggestions['key1'], $this->result->getSuggestion('key1'));
}
public function testGetInvalidSuggestion()
{
$this->assertNull($this->result->getSuggestion('key3'));
}
public function testGetSuggestions()
{
$this->assertEquals($this->suggestions, $this->result->getSuggestions());
}
public function testIterator()
{
$items = [];
foreach ($this->result as $key => $item) {
$items[$key] = $item;
}
$this->assertEquals($this->suggestions, $items);
}
public function testCount()
{
$this->assertSameSize($this->suggestions, $this->result);
}
}