Passed
Push — feature/initial-implementation ( f3915b...fbd338 )
by Fike
02:22
created

ClassMappingViewTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mergeDataProvider() 0 17 1
A shouldMergeViewsAsExpected() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Test\Suite\Unit\Entity\Mapping;
6
7
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMappingView;
8
use Codeception\Test\Unit;
9
use PHPUnit\Framework\Assert;
10
11
class ClassMappingViewTest extends Unit
12
{
13
    public function mergeDataProvider()
14
    {
15
        return [
16
            [
17
                [
18
                    (new ClassMappingView())
19
                        ->setType('type')
20
                        ->setParameters(['alpha' => 1, 'beta' => 1]),
21
                    (new ClassMappingView())
22
                        ->setType('object')
23
                        ->setParameters(['beta' => 2]),
24
                    (new ClassMappingView())
25
                        ->setParameters(['gamma' => 3])
26
                ],
27
                (new ClassMappingView())
28
                    ->setType('object')
29
                    ->setParameters(['alpha' => 1, 'beta' => 2, 'gamma' => 3])
30
            ]
31
        ];
32
    }
33
34
    /**
35
     * @param array $views
36
     * @param ClassMappingView $expectation
37
     *
38
     * @test
39
     * @dataProvider mergeDataProvider
40
     */
41
    public function shouldMergeViewsAsExpected(array $views, ClassMappingView $expectation)
42
    {
43
        $result = ClassMappingView::merge(...$views);
44
        Assert::assertEquals($expectation, $result);
45
    }
46
}
47