1 | <?php |
||
2 | |||
3 | namespace Bdf\Prime\Mapper; |
||
4 | |||
5 | require_once __DIR__.'/../../tests/_files/PrimeTestCase.php'; |
||
6 | require_once __DIR__.'/../../tests/_files/HydratorGeneration.php'; |
||
7 | require_once __DIR__.'/../../tests/_files/entity.php'; |
||
8 | require_once __DIR__.'/../../tests/_files/embedded.php'; |
||
9 | |||
10 | use Bdf\Prime\Bench\HydratorGeneration; |
||
11 | use Bdf\Prime\Entity\Hydrator\HydratorGeneratedInterface; |
||
12 | use Bdf\Prime\Entity\Hydrator\MapperHydrator; |
||
13 | use Bdf\Prime\PrimeTestCase; |
||
14 | use Bdf\Prime\TestEmbeddedEntity; |
||
0 ignored issues
–
show
|
|||
15 | use Bdf\Prime\TestEntity; |
||
0 ignored issues
–
show
The type
Bdf\Prime\TestEntity was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
16 | use Symfony\Component\Validator\Constraints\DateTime; |
||
17 | |||
18 | /** |
||
19 | * @Revs(3000) |
||
20 | */ |
||
21 | class HydrationBench extends \BenchCaseAdapter |
||
22 | { |
||
23 | use PrimeTestCase; |
||
24 | use HydratorGeneration; |
||
25 | |||
26 | /** |
||
27 | * @var Mapper |
||
28 | */ |
||
29 | protected $mapper; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $data; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $flatData; |
||
40 | |||
41 | /** |
||
42 | * @var HydratorGeneratedInterface |
||
43 | */ |
||
44 | protected $generatedHydrator; |
||
45 | |||
46 | /** |
||
47 | * @var MapperHydrator |
||
48 | */ |
||
49 | protected $defaultHydrator; |
||
50 | |||
51 | protected $entity; |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function setUp() |
||
57 | { |
||
58 | $this->primeStart(); |
||
59 | |||
60 | $this->mapper = TestEntity::repository()->mapper(); |
||
61 | $this->data = [ |
||
62 | "id" => 123, |
||
63 | "name" => "toto", |
||
64 | "dateInsert" => new DateTime(), |
||
65 | "foreign" => [ |
||
66 | "id" => 1587, |
||
67 | "name" => "Paul", |
||
68 | "city" => "Paris" |
||
69 | ] |
||
70 | ]; |
||
71 | |||
72 | $this->flatData = [ |
||
73 | "id" => 123, |
||
74 | "name" => "toto", |
||
75 | "dateInsert" => "2017-01-08 15:32:21", |
||
76 | "foreign.id" => 1587 |
||
77 | ]; |
||
78 | |||
79 | $this->generatedHydrator = $this->createHydrator(); |
||
80 | $this->defaultHydrator = new MapperHydrator(); |
||
81 | |||
82 | $this->entity = new TestEntity($this->data); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @Groups({"prepareToRepository"}) |
||
87 | */ |
||
88 | public function bench_prepareToRepository() |
||
89 | { |
||
90 | $this->mapper->setHydrator($this->defaultHydrator); |
||
91 | |||
92 | $this->mapper->prepareToRepository($this->entity); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @Groups({"prepareToRepository"}) |
||
97 | * |
||
98 | */ |
||
99 | public function bench_prepareToRepository_hydrator() |
||
100 | { |
||
101 | $this->mapper->setHydrator($this->generatedHydrator); |
||
102 | |||
103 | $this->mapper->prepareToRepository($this->entity); |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @Groups({"prepareFromRepository"}) |
||
108 | * |
||
109 | */ |
||
110 | public function bench_prepareFromRepository() |
||
111 | { |
||
112 | $this->mapper->setHydrator($this->defaultHydrator); |
||
113 | |||
114 | $platform = $this->mapper->repository()->connection()->platform(); |
||
115 | |||
116 | return $this->mapper->prepareFromRepository($this->flatData, $platform); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @Groups({"prepareFromRepository"}) |
||
121 | * |
||
122 | */ |
||
123 | public function bench_prepareFromRepository_hydrator() |
||
124 | { |
||
125 | $this->mapper->setHydrator($this->generatedHydrator); |
||
126 | |||
127 | $platform = $this->mapper->repository()->connection()->platform(); |
||
128 | |||
129 | return $this->mapper->prepareFromRepository($this->flatData, $platform); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * @Groups({"extractOne"}) |
||
134 | * |
||
135 | */ |
||
136 | public function bench_extractOne() |
||
137 | { |
||
138 | $this->mapper->setHydrator($this->defaultHydrator); |
||
139 | |||
140 | $this->mapper->extractOne($this->entity, "id"); |
||
141 | $this->mapper->extractOne($this->entity, "name"); |
||
142 | $this->mapper->extractOne($this->entity, "foreign.id"); |
||
143 | $this->mapper->extractOne($this->entity, "foreign"); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @Groups({"extractOne"}) |
||
148 | * |
||
149 | */ |
||
150 | public function bench_extractOne_hydrator() |
||
151 | { |
||
152 | $this->mapper->setHydrator($this->generatedHydrator); |
||
153 | |||
154 | $this->mapper->extractOne($this->entity, "id"); |
||
155 | $this->mapper->extractOne($this->entity, "name"); |
||
156 | $this->mapper->extractOne($this->entity, "foreign.id"); |
||
157 | $this->mapper->extractOne($this->entity, "foreign"); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @Groups({"hydrateOne"}) |
||
162 | * |
||
163 | */ |
||
164 | public function bench_hydrateOne() |
||
165 | { |
||
166 | $this->mapper->setHydrator($this->defaultHydrator); |
||
167 | |||
168 | $this->mapper->hydrateOne($this->entity, "id", 5); |
||
169 | $this->mapper->hydrateOne($this->entity, "name", "Test"); |
||
170 | $this->mapper->hydrateOne($this->entity, "foreign.id", 123); |
||
171 | $this->mapper->hydrateOne($this->entity, "foreign", new TestEmbeddedEntity()); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @Groups({"hydrateOne"}) |
||
176 | * |
||
177 | */ |
||
178 | public function bench_hydrateOne_hydrator() |
||
179 | { |
||
180 | $this->mapper->setHydrator($this->generatedHydrator); |
||
181 | |||
182 | $this->mapper->hydrateOne($this->entity, "id", 5); |
||
183 | $this->mapper->hydrateOne($this->entity, "name", "Test"); |
||
184 | $this->mapper->hydrateOne($this->entity, "foreign.id", 123); |
||
185 | $this->mapper->hydrateOne($this->entity, "foreign", new TestEmbeddedEntity()); |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * @return HydratorGeneratedInterface |
||
190 | */ |
||
191 | protected function createHydrator() |
||
192 | { |
||
193 | return $this->createGeneratedHydrator(TestEntity::class); |
||
194 | } |
||
195 | } |
||
196 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths