Passed
Push — feature/initial-implementation ( 0c2c6c...79751f )
by Fike
01:54
created

PropertyMappingViewTest::shouldMergeAsExpected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Test\Suite\Unit\Mapping;
6
7
use AmaTeam\ElasticSearch\Mapping\PropertyMappingView;
8
use Codeception\Test\Unit;
9
use PHPUnit\Framework\Assert;
10
11
class PropertyMappingViewTest extends Unit
12
{
13
    public function mergeDataProvider()
14
    {
15
        $variants = [];
16
        $variants[] = [
17
            [
18
                (new PropertyMappingView())
19
                    ->setTargetClass('alpha')
20
                    ->setType('alpha')
21
                    ->setParameter('alpha', 1)
22
                    ->setParameter('beta', 1),
23
                (new PropertyMappingView())
24
                    ->setTargetClass('beta')
25
                    ->setType('beta')
26
                    ->setParameter('beta', 2),
27
                (new PropertyMappingView())
28
                    ->setParameter('gamma', 3)
29
            ],
30
            (new PropertyMappingView())
31
                ->setTargetClass('beta')
32
                ->setType('beta')
33
                ->setParameters(['alpha' => 1, 'beta' => 2, 'gamma' => 3])
34
        ];
35
        return $variants;
36
    }
37
38
    /**
39
     * @param array $views
40
     * @param PropertyMappingView $expectation
41
     *
42
     * @test
43
     * @dataProvider mergeDataProvider
44
     */
45
    public function shouldMergeAsExpected(array $views, PropertyMappingView $expectation)
46
    {
47
        $result = PropertyMappingView::merge(...$views);
48
        Assert::assertEquals($expectation, $result);
49
    }
50
}
51