Passed
Push — feature/initial-implementation ( 70fbec...2d1ee1 )
by Fike
02:35
created

GiantBuildingExtractionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldExtractExpectedMapping() 0 48 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Test\Suite\Acceptance\Mapping;
6
7
use AmaTeam\ElasticSearch\Entity\Annotation\Loader;
8
use AmaTeam\ElasticSearch\Entity\Mapping\EntityProviderWrapperMappingProvider;
9
use AmaTeam\ElasticSearch\Entity\Provider;
10
use AmaTeam\ElasticSearch\Mapping\Manager;
11
use AmaTeam\ElasticSearch\Mapping\Mapping;
12
use AmaTeam\ElasticSearch\Mapping\Type\FloatType;
13
use AmaTeam\ElasticSearch\Mapping\Type\GeoPointType;
14
use AmaTeam\ElasticSearch\Mapping\Type\IntegerType;
15
use AmaTeam\ElasticSearch\Mapping\Type\KeywordType;
16
use AmaTeam\ElasticSearch\Mapping\Type\NestedType;
17
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\AnalyzerParameter;
18
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\CoerceParameter;
19
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\DocValuesParameter;
20
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\DynamicParameter;
21
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\FieldDataParameter;
22
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\IndexParameter;
23
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\NormsParameter;
24
use AmaTeam\ElasticSearch\Mapping\Type\RootType;
25
use AmaTeam\ElasticSearch\Mapping\Type\TextType;
26
use AmaTeam\ElasticSearch\Test\Support\ElasticSearch\Dummy\GiantBuilding;
27
use Codeception\Test\Unit;
28
use Doctrine\Common\Annotations\AnnotationRegistry;
29
use PHPUnit\Framework\Assert;
30
31
class GiantBuildingExtractionTest extends Unit
32
{
33
    /**
34
     * @test
35
     */
36
    public function shouldExtractExpectedMapping()
37
    {
38
        AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\Common\Annotati...istry::registerLoader() has been deprecated: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists') ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

38
        /** @scrutinizer ignore-deprecated */ AnnotationRegistry::registerLoader('class_exists');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
39
        $expectation = (new Mapping())
40
            ->setType(RootType::ID)
41
            ->setParameter(DynamicParameter::ID, true)
42
            ->setProperties([
43
                'id' => (new Mapping())
44
                    ->setType(IntegerType::ID)
45
                    ->setParameter(CoerceParameter::ID, true),
46
                'title' => (new Mapping())
47
                    ->setType(TextType::ID)
48
                    ->setParameter(AnalyzerParameter::ID, 'default')
49
                    ->setParameter(NormsParameter::ID, false)
50
                    ->setParameter(FieldDataParameter::ID, false),
51
                'category' => (new Mapping())
52
                    ->setType(KeywordType::ID)
53
                    ->setParameter(DocValuesParameter::ID, true),
54
                'location' => (new Mapping())
55
                    ->setType(GeoPointType::ID),
56
                'related' => (new Mapping())
57
                    ->setType(NestedType::ID)
58
                    ->setParameter(DynamicParameter::ID, false)
59
                    ->setProperties([
60
                        'id' => (new Mapping())
61
                            ->setType(IntegerType::ID)
62
                            ->setParameter(CoerceParameter::ID, true),
63
                        'title' => (new Mapping())
64
                            ->setType(TextType::ID)
65
                            ->setParameter(AnalyzerParameter::ID, 'default')
66
                            ->setParameter(NormsParameter::ID, false)
67
                            ->setParameter(FieldDataParameter::ID, false),
68
                        'category' => (new Mapping())
69
                            ->setType(KeywordType::ID)
70
                            ->setParameter(DocValuesParameter::ID, true),
71
                        'height' => (new Mapping())
72
                            ->setType(FloatType::ID)
73
                            ->setParameter(IndexParameter::ID, false),
74
                        'location' => (new Mapping())
75
                            ->setType(GeoPointType::ID),
76
                    ]),
77
                'giantness' => (new Mapping())
78
                    ->setType(FloatType::ID)
79
            ]);
80
        $provider = (new Provider())->registerLoader(new Loader());
81
        $manager = new Manager(new EntityProviderWrapperMappingProvider($provider));
82
        $mapping = $manager->get(GiantBuilding::class);
83
        Assert::assertEquals($expectation, $mapping);
84
    }
85
}
86