These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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
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. ![]() |
|||
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
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. ![]() |
|||
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) { |
|
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 |
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.