Completed
Push — master ( 9146c8...39ecb4 )
by Nicolas
04:52
created

VersionTest::assertVersions()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 30

Duplication

Lines 24
Ratio 80 %

Importance

Changes 0
Metric Value
dl 24
loc 30
c 0
b 0
f 0
rs 9.1288
cc 5
nc 16
nop 2
1
<?php
2
3
namespace Elastica\Test\QueryBuilder;
4
5
use Elastica\QueryBuilder\DSL;
6
use Elastica\QueryBuilder\Version;
7
use Elastica\Test\Base as BaseTest;
8
9
/**
10
 * @group unit
11
 *
12
 * @internal
13
 */
14
class VersionTest extends BaseTest
15
{
16
    public function testVersions(): void
17
    {
18
        $dsl = [
19
            new DSL\Query(),
20
            new DSL\Aggregation(),
21
            new DSL\Suggest(),
22
            new DSL\Collapse(),
23
        ];
24
25
        $versions = [
26
            new Version\Version700(),
27
            new Version\Latest(),
28
        ];
29
30
        foreach ($versions as $version) {
31
            $this->assertVersions($version, $dsl);
32
        }
33
    }
34
35
    private function assertVersions(Version $version, array $dsl): void
36
    {
37 View Code Duplication
        foreach ($version->getQueries() as $query) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            $this->assertTrue(
39
                \method_exists($dsl[0], $query),
40
                'query "'.$query.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[0])
41
            );
42
        }
43
44 View Code Duplication
        foreach ($version->getAggregations() as $aggregation) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
            $this->assertTrue(
46
                \method_exists($dsl[1], $aggregation),
47
                'aggregation "'.$aggregation.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[2])
48
            );
49
        }
50
51 View Code Duplication
        foreach ($version->getSuggesters() as $suggester) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
            $this->assertTrue(
53
                \method_exists($dsl[2], $suggester),
54
                'suggester "'.$suggester.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[2])
55
            );
56
        }
57
58 View Code Duplication
        foreach ($version->getCollapsers() as $collapser) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
            $this->assertTrue(
60
                \method_exists($dsl[3], $collapser),
61
                'suggester "'.$collapser.'" in '.\get_class($version).' must be defined in '.\get_class($dsl[3])
62
            );
63
        }
64
    }
65
}
66