forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResultTest.php
62 lines (51 loc) · 1.55 KB
/
ResultTest.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
<?php
namespace Solarium\Tests\Component\Result\Suggester;
use PHPUnit\Framework\TestCase;
use Solarium\Component\Result\Suggester\Result;
use Solarium\QueryType\Suggester\Result\Dictionary;
use Solarium\QueryType\Suggester\Result\Term;
class ResultTest extends TestCase
{
/**
* @var Result
*/
private $result;
/**
* @var array
*/
private $docs;
public function setUp(): void
{
$this->docs = [
'dictionary1' => new Dictionary([
'foo' => new Term(2, [['term' => 'foo'], ['term' => 'foobar']]),
'zoo' => new Term(1, [['term' => 'zoo keeper']]),
]),
'dictionary2' => new Dictionary([
'free' => new Term(2, [['term' => 'free beer'], ['term' => 'free software']]),
]),
];
$all = [
new Term(2, [['term' => 'foo'], ['term' => 'foobar']]),
new Term(1, [['term' => 'zoo keeper']]),
new Term(2, [['term' => 'free beer'], ['term' => 'free software']]),
];
$this->result = new Result($this->docs, $all);
}
public function testGetDictionary()
{
$this->assertEquals($this->docs['dictionary1'], $this->result->getDictionary('dictionary1'));
}
public function testIterator()
{
$docs = [];
foreach ($this->result as $key => $doc) {
$docs[$key] = $doc;
}
$this->assertEquals($this->docs, $docs);
}
public function testCount()
{
$this->assertSameSize($this->docs, $this->result);
}
}