|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Stinger Entity Search package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Oliver Kotte <[email protected]> |
|
7
|
|
|
* (c) Florian Meyer <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace StingerSoft\EntitySearchBundle\Tests\Model\Result; |
|
13
|
|
|
|
|
14
|
|
|
use StingerSoft\EntitySearchBundle\Model\Result\FacetSetAdapter; |
|
15
|
|
|
use StingerSoft\EntitySearchBundle\Model\Document; |
|
16
|
|
|
|
|
17
|
|
|
class FacetSetAdapterTest extends \PHPUnit_Framework_TestCase { |
|
18
|
|
|
|
|
19
|
|
|
public function testAddFacetValue(){ |
|
20
|
|
|
$facets = new FacetSetAdapter(array()); |
|
21
|
|
|
$this->assertCount(0, $facets); |
|
22
|
|
|
$facets->addFacetValue(Document::FIELD_AUTHOR, 'Oliver Kotte'); |
|
23
|
|
|
$this->assertCount(1, $facets); |
|
24
|
|
|
$this->assertCount(1, $facets->getFacet(Document::FIELD_AUTHOR)); |
|
25
|
|
|
$facets->addFacetValue(Document::FIELD_AUTHOR, 'Florian Meyer'); |
|
26
|
|
|
$this->assertCount(1, $facets); |
|
27
|
|
|
$this->assertCount(2, $facets->getFacet(Document::FIELD_AUTHOR)); |
|
28
|
|
|
|
|
29
|
|
|
foreach($facets as $facetKey => $facetValues){ |
|
30
|
|
|
$this->assertEquals(Document::FIELD_AUTHOR, $facetKey); |
|
31
|
|
|
$this->assertCount(2, $facetValues); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testGetFacet(){ |
|
36
|
|
|
$facets = new FacetSetAdapter(array()); |
|
37
|
|
|
$this->assertCount(0, $facets); |
|
38
|
|
|
$this->assertNull($facets->getFacet('NotExisting')); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
} |