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; |
13
|
|
|
|
14
|
|
|
use StingerSoft\EntitySearchBundle\Model\Query; |
15
|
|
|
use StingerSoft\EntitySearchBundle\Model\Document; |
16
|
|
|
|
17
|
|
|
class QueryTest extends \PHPUnit_Framework_TestCase { |
18
|
|
|
|
19
|
|
|
public function testSetGetFacets() { |
20
|
|
|
$query = new Query(); |
21
|
|
|
$facets = array( |
22
|
|
|
Document::FIELD_AUTHOR => array( |
23
|
|
|
'Oliver Kotte', |
24
|
|
|
'Florian Meyer' |
25
|
|
|
) |
26
|
|
|
); |
27
|
|
|
$query->setFacets($facets); |
28
|
|
|
$this->assertEquals($facets, $query->getFacets()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testSetGetUsedFacets() { |
32
|
|
|
$query = new Query(); |
33
|
|
|
$facets = array( |
34
|
|
|
Document::FIELD_AUTHOR, |
35
|
|
|
); |
36
|
|
|
$query->setUsedFacets($facets); |
37
|
|
|
$this->assertEquals($facets, $query->getUsedFacets()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testMagicMethods() { |
41
|
|
|
$facets = array( |
42
|
|
|
Document::FIELD_AUTHOR => array( |
43
|
|
|
'Oliver Kotte', |
44
|
|
|
'Florian Meyer' |
45
|
|
|
) |
46
|
|
|
); |
47
|
|
|
$query = new Query(null, $facets); |
48
|
|
|
|
49
|
|
|
$this->assertTrue($query->__isset('facet_'.Document::FIELD_AUTHOR)); |
50
|
|
|
$this->assertEquals($facets[Document::FIELD_AUTHOR], $query->__get('facet_'.Document::FIELD_AUTHOR)); |
51
|
|
|
|
52
|
|
|
$this->assertTrue($query->__isset('facet_'.Document::FIELD_CONTENT)); |
53
|
|
|
$this->assertEmpty($query->__get('facet_'.Document::FIELD_CONTENT)); |
54
|
|
|
|
55
|
|
|
$this->assertFalse($query->__isset('WrongPrefixedPropety')); |
56
|
|
|
$this->assertNull($query->__get('WrongPrefixedPropety')); |
57
|
|
|
|
58
|
|
|
$query->__set('facet_'.Document::FIELD_EDITORS, $facets[Document::FIELD_AUTHOR]); |
59
|
|
|
$this->assertEquals($facets[Document::FIELD_AUTHOR], $query->__get('facet_'.Document::FIELD_EDITORS)); |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |