1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stinger Enity 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\DocumentAdapter; |
15
|
|
|
use StingerSoft\EntitySearchBundle\Tests\Fixtures\ORM\Beer; |
16
|
|
|
use StingerSoft\EntitySearchBundle\Model\Document; |
17
|
|
|
|
18
|
|
|
class DocumentAdapterTest extends \PHPUnit_Framework_TestCase { |
19
|
|
|
|
20
|
|
|
public function testAddFields() { |
21
|
|
|
$doc = new DocumentAdapter(); |
22
|
|
|
|
23
|
|
|
$doc->setEntityClass(Beer::class); |
24
|
|
|
$doc->setEntityId(1); |
25
|
|
|
$doc->addField(Document::FIELD_AUTHOR, 'florian_meyer'); |
26
|
|
|
$doc->addMultiValueField(Document::FIELD_EDITORS, 'florian_meyer'); |
27
|
|
|
$doc->addMultiValueField(Document::FIELD_EDITORS, 'oliver_kotte'); |
28
|
|
|
|
29
|
|
|
$this->assertEquals(Beer::class, $doc->getEntityClass()); |
30
|
|
|
$this->assertEquals(1, $doc->getEntityId()); |
31
|
|
|
|
32
|
|
|
$fields = $doc->getFields(); |
33
|
|
|
$this->assertArrayHasKey(Document::FIELD_AUTHOR, $fields); |
34
|
|
|
$this->assertNotNull($doc->getFieldValue(Document::FIELD_AUTHOR)); |
35
|
|
|
$this->assertArrayHasKey(Document::FIELD_EDITORS, $fields); |
36
|
|
|
$this->assertNotNull($doc->getFieldValue(Document::FIELD_EDITORS)); |
37
|
|
|
$this->assertContains('florian_meyer', $fields[Document::FIELD_EDITORS]); |
38
|
|
|
|
39
|
|
|
$this->assertNull($doc->getFieldValue(Document::FIELD_ROLES)); |
40
|
|
|
} |
41
|
|
|
} |