1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOSElasticaBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FOS\ElasticaBundle\Tests\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use FOS\ElasticaBundle\DependencyInjection\FOSElasticaExtension; |
15
|
|
|
use FOS\ElasticaBundle\Doctrine\Listener; |
16
|
|
|
use FOS\ElasticaBundle\Doctrine\RegisterListenersService; |
17
|
|
|
use FOS\ElasticaBundle\Doctrine\MongoDBPagerProvider; |
18
|
|
|
use FOS\ElasticaBundle\Doctrine\ORMPagerProvider; |
19
|
|
|
use FOS\ElasticaBundle\Doctrine\PHPCRPagerProvider; |
20
|
|
|
use FOS\ElasticaBundle\Persister\InPlacePagerPersister; |
21
|
|
|
use FOS\ElasticaBundle\Persister\Listener\FilterObjectsListener; |
22
|
|
|
use FOS\ElasticaBundle\Persister\PagerPersisterRegistry; |
23
|
|
|
use FOS\ElasticaBundle\Propel\Propel1PagerProvider; |
24
|
|
|
use PHPUnit\Framework\TestCase; |
25
|
|
|
use Symfony\Component\DependencyInjection\ChildDefinition; |
26
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
27
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
28
|
|
|
use Symfony\Component\Yaml\Yaml; |
29
|
|
|
|
30
|
|
|
class FOSElasticaExtensionTest extends TestCase |
31
|
|
|
{ |
32
|
|
|
public function testShouldAddParentParamToObjectPersisterCall() |
33
|
|
|
{ |
34
|
|
|
$config = Yaml::parse(file_get_contents(__DIR__.'/fixtures/config.yml')); |
35
|
|
|
|
36
|
|
|
$containerBuilder = new ContainerBuilder(); |
37
|
|
|
$containerBuilder->setParameter('kernel.debug', true); |
38
|
|
|
|
39
|
|
|
$extension = new FOSElasticaExtension(); |
40
|
|
|
|
41
|
|
|
$extension->load($config, $containerBuilder); |
42
|
|
|
|
43
|
|
|
$this->assertTrue($containerBuilder->hasDefinition('fos_elastica.object_persister.test_index.child_field')); |
44
|
|
|
|
45
|
|
|
$persisterCallDefinition = $containerBuilder->getDefinition('fos_elastica.object_persister.test_index.child_field'); |
46
|
|
|
|
47
|
|
|
$arguments = $persisterCallDefinition->getArguments(); |
48
|
|
|
$arguments = $arguments['index_3']; |
49
|
|
|
|
50
|
|
|
$this->assertArrayHasKey('_parent', $arguments); |
51
|
|
|
$this->assertSame('parent_field', $arguments['_parent']['type']); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testExtensionSupportsDriverlessTypePersistence() |
55
|
|
|
{ |
56
|
|
|
$config = Yaml::parse(file_get_contents(__DIR__.'/fixtures/driverless_type.yml')); |
57
|
|
|
|
58
|
|
|
$containerBuilder = new ContainerBuilder(); |
59
|
|
|
$containerBuilder->setParameter('kernel.debug', true); |
60
|
|
|
|
61
|
|
|
$extension = new FOSElasticaExtension(); |
62
|
|
|
$extension->load($config, $containerBuilder); |
63
|
|
|
|
64
|
|
|
$this->assertTrue($containerBuilder->hasDefinition('fos_elastica.index.test_index')); |
65
|
|
|
$this->assertTrue($containerBuilder->hasDefinition('fos_elastica.index.test_index.driverless')); |
66
|
|
|
$this->assertFalse($containerBuilder->hasDefinition('fos_elastica.elastica_to_model_transformer.test_index.driverless')); |
67
|
|
|
$this->assertFalse($containerBuilder->hasDefinition('fos_elastica.object_persister.test_index.driverless')); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
View Code Duplication |
public function testShouldRegisterDoctrineORMPagerProviderIfEnabled() |
71
|
|
|
{ |
72
|
|
|
$container = new ContainerBuilder(); |
73
|
|
|
$container->setParameter('kernel.debug', true); |
74
|
|
|
|
75
|
|
|
$extension = new FOSElasticaExtension(); |
76
|
|
|
$extension->load([ |
77
|
|
|
'fos_elastica' => [ |
78
|
|
|
'clients' => [ |
79
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
80
|
|
|
], |
81
|
|
|
'indexes' => [ |
82
|
|
|
'acme_index' => [ |
83
|
|
|
'types' => [ |
84
|
|
|
'acme_type' => [ |
85
|
|
|
'properties' => ['text' => null], |
86
|
|
|
'persistence' => [ |
87
|
|
|
'driver' => 'orm', |
88
|
|
|
'model' => 'theModelClass', |
89
|
|
|
'provider' => null, |
90
|
|
|
'listener' => null, |
91
|
|
|
'finder' => null, |
92
|
|
|
] |
93
|
|
|
] |
94
|
|
|
] |
95
|
|
|
] |
96
|
|
|
] |
97
|
|
|
] |
98
|
|
|
], $container); |
99
|
|
|
|
100
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.acme_index.acme_type')); |
101
|
|
|
|
102
|
|
|
$definition = $container->getDefinition('fos_elastica.pager_provider.acme_index.acme_type'); |
103
|
|
|
$this->assertInstanceOf(ChildDefinition::class, $definition); |
104
|
|
|
$this->assertSame('fos_elastica.pager_provider.prototype.orm', $definition->getParent()); |
105
|
|
|
$this->assertSame('theModelClass', $definition->getArgument(2)); |
106
|
|
|
$this->assertSame([ |
107
|
|
|
'batch_size' => 100, |
108
|
|
|
'clear_object_manager' => true, |
109
|
|
|
'debug_logging' => true, |
110
|
|
|
'query_builder_method' => 'createQueryBuilder', |
111
|
|
|
], $definition->getArgument(3)); |
112
|
|
|
|
113
|
|
|
$this->assertSame([ |
114
|
|
|
'fos_elastica.pager_provider' => [ |
115
|
|
|
['index' => 'acme_index', 'type' => 'acme_type'], |
116
|
|
|
] |
117
|
|
|
], $definition->getTags()); |
118
|
|
|
|
119
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.prototype.orm')); |
120
|
|
|
$this->assertSame( |
121
|
|
|
ORMPagerProvider::class, |
122
|
|
|
$container->getDefinition('fos_elastica.pager_provider.prototype.orm')->getClass() |
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
View Code Duplication |
public function testShouldRegisterDoctrineMongoDBPagerProviderIfEnabled() |
127
|
|
|
{ |
128
|
|
|
if (!class_exists(\Doctrine\ODM\MongoDB\DocumentManager::class)) { |
129
|
|
|
$this->markTestSkipped('Doctrine MongoDB ODM is not available.'); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
$container = new ContainerBuilder(); |
133
|
|
|
$container->setParameter('kernel.debug', true); |
134
|
|
|
|
135
|
|
|
$extension = new FOSElasticaExtension(); |
136
|
|
|
$extension->load([ |
137
|
|
|
'fos_elastica' => [ |
138
|
|
|
'clients' => [ |
139
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
140
|
|
|
], |
141
|
|
|
'indexes' => [ |
142
|
|
|
'acme_index' => [ |
143
|
|
|
'types' => [ |
144
|
|
|
'acme_type' => [ |
145
|
|
|
'properties' => ['text' => null], |
146
|
|
|
'persistence' => [ |
147
|
|
|
'driver' => 'mongodb', |
148
|
|
|
'model' => 'theModelClass', |
149
|
|
|
'provider' => null, |
150
|
|
|
'listener' => null, |
151
|
|
|
'finder' => null, |
152
|
|
|
] |
153
|
|
|
] |
154
|
|
|
] |
155
|
|
|
] |
156
|
|
|
] |
157
|
|
|
] |
158
|
|
|
], $container); |
159
|
|
|
|
160
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.acme_index.acme_type')); |
161
|
|
|
|
162
|
|
|
$definition = $container->getDefinition('fos_elastica.pager_provider.acme_index.acme_type'); |
163
|
|
|
$this->assertInstanceOf(ChildDefinition::class, $definition); |
164
|
|
|
$this->assertSame('fos_elastica.pager_provider.prototype.mongodb', $definition->getParent()); |
165
|
|
|
$this->assertSame('theModelClass', $definition->getArgument(2)); |
166
|
|
|
$this->assertSame([ |
167
|
|
|
'batch_size' => 100, |
168
|
|
|
'clear_object_manager' => true, |
169
|
|
|
'debug_logging' => true, |
170
|
|
|
'query_builder_method' => 'createQueryBuilder', |
171
|
|
|
], $definition->getArgument(3)); |
172
|
|
|
|
173
|
|
|
$this->assertSame([ |
174
|
|
|
'fos_elastica.pager_provider' => [ |
175
|
|
|
['index' => 'acme_index', 'type' => 'acme_type'], |
176
|
|
|
] |
177
|
|
|
], $definition->getTags()); |
178
|
|
|
|
179
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.prototype.mongodb')); |
180
|
|
|
$this->assertSame( |
181
|
|
|
MongoDBPagerProvider::class, |
182
|
|
|
$container->getDefinition('fos_elastica.pager_provider.prototype.mongodb')->getClass() |
183
|
|
|
); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
View Code Duplication |
public function testShouldRegisterDoctrinePHPCRPagerProviderIfEnabled() |
187
|
|
|
{ |
188
|
|
|
if (!class_exists(\Doctrine\ODM\PHPCR\DocumentManager::class)) { |
189
|
|
|
$this->markTestSkipped('Doctrine PHPCR is not present'); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
$container = new ContainerBuilder(); |
193
|
|
|
$container->setParameter('kernel.debug', true); |
194
|
|
|
|
195
|
|
|
$extension = new FOSElasticaExtension(); |
196
|
|
|
$extension->load([ |
197
|
|
|
'fos_elastica' => [ |
198
|
|
|
'clients' => [ |
199
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
200
|
|
|
], |
201
|
|
|
'indexes' => [ |
202
|
|
|
'acme_index' => [ |
203
|
|
|
'types' => [ |
204
|
|
|
'acme_type' => [ |
205
|
|
|
'properties' => ['text' => null], |
206
|
|
|
'persistence' => [ |
207
|
|
|
'driver' => 'phpcr', |
208
|
|
|
'model' => 'theModelClass', |
209
|
|
|
'provider' => null, |
210
|
|
|
'listener' => null, |
211
|
|
|
'finder' => null, |
212
|
|
|
] |
213
|
|
|
] |
214
|
|
|
] |
215
|
|
|
] |
216
|
|
|
] |
217
|
|
|
] |
218
|
|
|
], $container); |
219
|
|
|
|
220
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.acme_index.acme_type')); |
221
|
|
|
|
222
|
|
|
$definition = $container->getDefinition('fos_elastica.pager_provider.acme_index.acme_type'); |
223
|
|
|
$this->assertInstanceOf(ChildDefinition::class, $definition); |
224
|
|
|
$this->assertSame('fos_elastica.pager_provider.prototype.phpcr', $definition->getParent()); |
225
|
|
|
$this->assertSame('theModelClass', $definition->getArgument(2)); |
226
|
|
|
$this->assertSame([ |
227
|
|
|
'batch_size' => 100, |
228
|
|
|
'clear_object_manager' => true, |
229
|
|
|
'debug_logging' => true, |
230
|
|
|
'query_builder_method' => 'createQueryBuilder', |
231
|
|
|
], $definition->getArgument(3)); |
232
|
|
|
|
233
|
|
|
$this->assertSame([ |
234
|
|
|
'fos_elastica.pager_provider' => [ |
235
|
|
|
['index' => 'acme_index', 'type' => 'acme_type'], |
236
|
|
|
] |
237
|
|
|
], $definition->getTags()); |
238
|
|
|
|
239
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.prototype.phpcr')); |
240
|
|
|
$this->assertSame( |
241
|
|
|
PHPCRPagerProvider::class, |
242
|
|
|
$container->getDefinition('fos_elastica.pager_provider.prototype.phpcr')->getClass() |
243
|
|
|
); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
View Code Duplication |
public function testShouldRegisterPropel1PagerProviderIfEnabled() |
247
|
|
|
{ |
248
|
|
|
$container = new ContainerBuilder(); |
249
|
|
|
$container->setParameter('kernel.debug', true); |
250
|
|
|
|
251
|
|
|
$extension = new FOSElasticaExtension(); |
252
|
|
|
$extension->load([ |
253
|
|
|
'fos_elastica' => [ |
254
|
|
|
'clients' => [ |
255
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
256
|
|
|
], |
257
|
|
|
'indexes' => [ |
258
|
|
|
'acme_index' => [ |
259
|
|
|
'types' => [ |
260
|
|
|
'acme_type' => [ |
261
|
|
|
'properties' => ['text' => null], |
262
|
|
|
'persistence' => [ |
263
|
|
|
'driver' => 'propel', |
264
|
|
|
'model' => 'theModelClass', |
265
|
|
|
'provider' => null, |
266
|
|
|
'listener' => null, |
267
|
|
|
'finder' => null, |
268
|
|
|
] |
269
|
|
|
] |
270
|
|
|
] |
271
|
|
|
] |
272
|
|
|
] |
273
|
|
|
] |
274
|
|
|
], $container); |
275
|
|
|
|
276
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.acme_index.acme_type')); |
277
|
|
|
|
278
|
|
|
$definition = $container->getDefinition('fos_elastica.pager_provider.acme_index.acme_type'); |
279
|
|
|
$this->assertInstanceOf(ChildDefinition::class, $definition); |
280
|
|
|
$this->assertSame('fos_elastica.pager_provider.prototype.propel', $definition->getParent()); |
281
|
|
|
$this->assertSame('theModelClass', $definition->getArgument(0)); |
282
|
|
|
$this->assertSame([ |
283
|
|
|
'batch_size' => 100, |
284
|
|
|
'clear_object_manager' => true, |
285
|
|
|
'debug_logging' => true, |
286
|
|
|
'query_builder_method' => 'createQueryBuilder', |
287
|
|
|
], $definition->getArgument(1)); |
288
|
|
|
|
289
|
|
|
$this->assertSame([ |
290
|
|
|
'fos_elastica.pager_provider' => [ |
291
|
|
|
['index' => 'acme_index', 'type' => 'acme_type'], |
292
|
|
|
] |
293
|
|
|
], $definition->getTags()); |
294
|
|
|
|
295
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_provider.prototype.propel')); |
296
|
|
|
$this->assertSame( |
297
|
|
|
Propel1PagerProvider::class, |
298
|
|
|
$container->getDefinition('fos_elastica.pager_provider.prototype.propel')->getClass() |
299
|
|
|
); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
public function testShouldRegisterInPlacePagerPersister() |
303
|
|
|
{ |
304
|
|
|
$container = new ContainerBuilder(); |
305
|
|
|
$container->setParameter('kernel.debug', true); |
306
|
|
|
|
307
|
|
|
$extension = new FOSElasticaExtension(); |
308
|
|
|
$extension->load([ |
309
|
|
|
'fos_elastica' => [ |
310
|
|
|
'clients' => [ |
311
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
312
|
|
|
], |
313
|
|
|
'indexes' => [ |
314
|
|
|
'acme_index' => [ |
315
|
|
|
'types' => [ |
316
|
|
|
'acme_type' => [ |
317
|
|
|
'properties' => ['text' => null], |
318
|
|
|
'persistence' => [ |
319
|
|
|
'driver' => 'propel', |
320
|
|
|
'model' => 'theModelClass', |
321
|
|
|
'provider' => null, |
322
|
|
|
'listener' => null, |
323
|
|
|
'finder' => null, |
324
|
|
|
] |
325
|
|
|
] |
326
|
|
|
] |
327
|
|
|
] |
328
|
|
|
] |
329
|
|
|
] |
330
|
|
|
], $container); |
331
|
|
|
|
332
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.in_place_pager_persister')); |
333
|
|
|
|
334
|
|
|
$definition = $container->getDefinition('fos_elastica.in_place_pager_persister'); |
335
|
|
|
$this->assertSame(InPlacePagerPersister::class, $definition->getClass()); |
336
|
|
|
|
337
|
|
|
$this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
338
|
|
|
$this->assertSame('fos_elastica.persister_registry', (string) $definition->getArgument(0)); |
339
|
|
|
|
340
|
|
|
$this->assertInstanceOf(Reference::class, $definition->getArgument(1)); |
341
|
|
|
$this->assertSame('event_dispatcher', (string) $definition->getArgument(1)); |
342
|
|
|
|
343
|
|
|
$this->assertSame([ |
344
|
|
|
'fos_elastica.pager_persister' => [['persisterName' => 'in_place']] |
345
|
|
|
], $definition->getTags()); |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
public function testShouldRegisterRegisterListenersServiceForDoctrineProvider() |
349
|
|
|
{ |
350
|
|
|
$container = new ContainerBuilder(); |
351
|
|
|
$container->setParameter('kernel.debug', true); |
352
|
|
|
|
353
|
|
|
$extension = new FOSElasticaExtension(); |
354
|
|
|
$extension->load([ |
355
|
|
|
'fos_elastica' => [ |
356
|
|
|
'clients' => [ |
357
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
358
|
|
|
], |
359
|
|
|
'indexes' => [ |
360
|
|
|
'acme_index' => [ |
361
|
|
|
'types' => [ |
362
|
|
|
'acme_type' => [ |
363
|
|
|
'properties' => ['text' => null], |
364
|
|
|
'persistence' => [ |
365
|
|
|
'driver' => 'orm', |
366
|
|
|
'model' => 'theModelClass', |
367
|
|
|
'provider' => null, |
368
|
|
|
'listener' => null, |
369
|
|
|
'finder' => null, |
370
|
|
|
] |
371
|
|
|
] |
372
|
|
|
] |
373
|
|
|
] |
374
|
|
|
] |
375
|
|
|
] |
376
|
|
|
], $container); |
377
|
|
|
|
378
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.doctrine.register_listeners')); |
379
|
|
|
|
380
|
|
|
$definition = $container->getDefinition('fos_elastica.doctrine.register_listeners'); |
381
|
|
|
$this->assertSame(RegisterListenersService::class, $definition->getClass()); |
382
|
|
|
|
383
|
|
|
$this->assertInstanceOf(Reference::class, $definition->getArgument(0)); |
384
|
|
|
$this->assertSame('event_dispatcher', (string) $definition->getArgument(0)); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
View Code Duplication |
public function testShouldNotRegisterRegisterListenersServiceForNotDoctrineProvider() |
388
|
|
|
{ |
389
|
|
|
$container = new ContainerBuilder(); |
390
|
|
|
$container->setParameter('kernel.debug', true); |
391
|
|
|
|
392
|
|
|
$extension = new FOSElasticaExtension(); |
393
|
|
|
$extension->load([ |
394
|
|
|
'fos_elastica' => [ |
395
|
|
|
'clients' => [ |
396
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
397
|
|
|
], |
398
|
|
|
'indexes' => [ |
399
|
|
|
'acme_index' => [ |
400
|
|
|
'types' => [ |
401
|
|
|
'acme_type' => [ |
402
|
|
|
'properties' => ['text' => null], |
403
|
|
|
'persistence' => [ |
404
|
|
|
'driver' => 'propel', |
405
|
|
|
'model' => 'theModelClass', |
406
|
|
|
'provider' => null, |
407
|
|
|
'listener' => null, |
408
|
|
|
'finder' => null, |
409
|
|
|
] |
410
|
|
|
] |
411
|
|
|
] |
412
|
|
|
] |
413
|
|
|
] |
414
|
|
|
] |
415
|
|
|
], $container); |
416
|
|
|
|
417
|
|
|
$this->assertFalse($container->hasDefinition('fos_elastica.doctrine.register_listeners')); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
public function testShouldRegisterFilterObjectsListener() |
421
|
|
|
{ |
422
|
|
|
$container = new ContainerBuilder(); |
423
|
|
|
$container->setParameter('kernel.debug', true); |
424
|
|
|
|
425
|
|
|
$extension = new FOSElasticaExtension(); |
426
|
|
|
$extension->load([ |
427
|
|
|
'fos_elastica' => [ |
428
|
|
|
'clients' => [ |
429
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
430
|
|
|
], |
431
|
|
|
'indexes' => [ |
432
|
|
|
'acme_index' => [ |
433
|
|
|
'types' => [ |
434
|
|
|
'acme_type' => [ |
435
|
|
|
'properties' => ['text' => null], |
436
|
|
|
'persistence' => [ |
437
|
|
|
'driver' => 'propel', |
438
|
|
|
'model' => 'theModelClass', |
439
|
|
|
'provider' => null, |
440
|
|
|
'listener' => null, |
441
|
|
|
'finder' => null, |
442
|
|
|
] |
443
|
|
|
] |
444
|
|
|
] |
445
|
|
|
] |
446
|
|
|
] |
447
|
|
|
] |
448
|
|
|
], $container); |
449
|
|
|
|
450
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.filter_objects_listener')); |
451
|
|
|
|
452
|
|
|
$listener = $container->getDefinition('fos_elastica.filter_objects_listener'); |
453
|
|
|
|
454
|
|
|
$this->assertSame(FilterObjectsListener::class, $listener->getClass()); |
455
|
|
|
|
456
|
|
|
$this->assertInstanceOf(Reference::class, $listener->getArgument(0)); |
457
|
|
|
$this->assertSame('fos_elastica.indexable', (string) $listener->getArgument(0)); |
458
|
|
|
$this->assertEquals(['kernel.event_subscriber' => [[]]], $listener->getTags()); |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
public function testShouldRegisterPagerPersisterRegisterService() |
462
|
|
|
{ |
463
|
|
|
$container = new ContainerBuilder(); |
464
|
|
|
$container->setParameter('kernel.debug', true); |
465
|
|
|
|
466
|
|
|
$extension = new FOSElasticaExtension(); |
467
|
|
|
$extension->load([ |
468
|
|
|
'fos_elastica' => [ |
469
|
|
|
'clients' => [ |
470
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
471
|
|
|
], |
472
|
|
|
'indexes' => [ |
473
|
|
|
'acme_index' => [ |
474
|
|
|
'types' => [ |
475
|
|
|
'acme_type' => [ |
476
|
|
|
'properties' => ['text' => null], |
477
|
|
|
'persistence' => [ |
478
|
|
|
'driver' => 'propel', |
479
|
|
|
'model' => 'theModelClass', |
480
|
|
|
'provider' => null, |
481
|
|
|
'listener' => null, |
482
|
|
|
'finder' => null, |
483
|
|
|
] |
484
|
|
|
] |
485
|
|
|
] |
486
|
|
|
] |
487
|
|
|
] |
488
|
|
|
] |
489
|
|
|
], $container); |
490
|
|
|
|
491
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.pager_persister_registry')); |
492
|
|
|
|
493
|
|
|
$listener = $container->getDefinition('fos_elastica.pager_persister_registry'); |
494
|
|
|
$this->assertSame(PagerPersisterRegistry::class, $listener->getClass()); |
495
|
|
|
$this->assertSame([], $listener->getArgument(0)); |
496
|
|
|
} |
497
|
|
|
|
498
|
|
View Code Duplication |
public function testShouldRegisterDoctrineORMListener() |
499
|
|
|
{ |
500
|
|
|
$container = new ContainerBuilder(); |
501
|
|
|
$container->setParameter('kernel.debug', true); |
502
|
|
|
|
503
|
|
|
$extension = new FOSElasticaExtension(); |
504
|
|
|
$extension->load([ |
505
|
|
|
'fos_elastica' => [ |
506
|
|
|
'clients' => [ |
507
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
508
|
|
|
], |
509
|
|
|
'indexes' => [ |
510
|
|
|
'acme_index' => [ |
511
|
|
|
'types' => [ |
512
|
|
|
'acme_type' => [ |
513
|
|
|
'properties' => ['text' => null], |
514
|
|
|
'persistence' => [ |
515
|
|
|
'driver' => 'orm', |
516
|
|
|
'model' => 'theModelClass', |
517
|
|
|
'provider' => null, |
518
|
|
|
'listener' => null, |
519
|
|
|
'finder' => null, |
520
|
|
|
] |
521
|
|
|
] |
522
|
|
|
] |
523
|
|
|
] |
524
|
|
|
] |
525
|
|
|
] |
526
|
|
|
], $container); |
527
|
|
|
|
528
|
|
|
$this->assertTrue($container->hasDefinition('fos_elastica.listener.acme_index.acme_type')); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
View Code Duplication |
public function testShouldNotRegisterDoctrineORMListenerIfDisabled() |
532
|
|
|
{ |
533
|
|
|
$container = new ContainerBuilder(); |
534
|
|
|
$container->setParameter('kernel.debug', true); |
535
|
|
|
|
536
|
|
|
$extension = new FOSElasticaExtension(); |
537
|
|
|
$extension->load([ |
538
|
|
|
'fos_elastica' => [ |
539
|
|
|
'clients' => [ |
540
|
|
|
'default' => ['host' => 'a_host', 'port' => 'a_port'], |
541
|
|
|
], |
542
|
|
|
'indexes' => [ |
543
|
|
|
'acme_index' => [ |
544
|
|
|
'types' => [ |
545
|
|
|
'acme_type' => [ |
546
|
|
|
'properties' => ['text' => null], |
547
|
|
|
'persistence' => [ |
548
|
|
|
'driver' => 'orm', |
549
|
|
|
'model' => 'theModelClass', |
550
|
|
|
'provider' => null, |
551
|
|
|
'listener' => [ |
552
|
|
|
'enabled' => false, |
553
|
|
|
], |
554
|
|
|
'finder' => null, |
555
|
|
|
] |
556
|
|
|
] |
557
|
|
|
] |
558
|
|
|
] |
559
|
|
|
] |
560
|
|
|
] |
561
|
|
|
], $container); |
562
|
|
|
|
563
|
|
|
$this->assertFalse($container->hasDefinition('fos_elastica.listener.acme_index.acme_type')); |
564
|
|
|
} |
565
|
|
|
} |
566
|
|
|
|