Completed
Push — 3.1.x ( fd2df9...19ca60 )
by Tim
05:29 queued 12s
created

MappingBuilderTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace FOS\ElasticaBundle\Tests\Index;
4
5
use FOS\ElasticaBundle\Configuration\TypeConfig;
6
use FOS\ElasticaBundle\Index\MappingBuilder;
7
8
class MappingBuilderTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @var MappingBuilder
12
     */
13
    private $builder;
14
15
    protected function setUp()
16
    {
17
        $this->builder = new MappingBuilder();
18
    }
19
20
    public function testMappingBuilderStoreProperty()
21
    {
22
        $typeConfig = new TypeConfig('typename', [
23
            'properties' => [
24
                'storeless' => [
25
                    'type' => 'string'
26
                ],
27
                'stored' => [
28
                    'type' => 'string',
29
                    'store' => true
30
                ],
31
                'unstored' => [
32
                    'type' => 'string',
33
                    'store' => false
34
                ],
35
            ]
36
        ]);
37
38
        $mapping = $this->builder->buildTypeMapping($typeConfig);
39
40
        $this->assertArrayNotHasKey('store', $mapping['properties']['storeless']);
41
        $this->assertArrayHasKey('store', $mapping['properties']['stored']);
42
        $this->assertTrue($mapping['properties']['stored']['store']);
43
        $this->assertArrayHasKey('store', $mapping['properties']['unstored']);
44
        $this->assertFalse($mapping['properties']['unstored']['store']);
45
    }
46
47
}