1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the EzPublishCoreExtensionTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection; |
10
|
|
|
|
11
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\QueryTypePass; |
12
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Common; |
13
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Content; |
14
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension; |
15
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Stub\QueryTypeBundle\QueryType\TestQueryType; |
16
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Stub\StubPolicyProvider; |
17
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
18
|
|
|
use Symfony\Component\Config\FileLocator; |
19
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass; |
20
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
21
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
22
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
23
|
|
|
use Symfony\Component\Yaml\Yaml; |
24
|
|
|
|
25
|
|
|
class EzPublishCoreExtensionTest extends AbstractExtensionTestCase |
26
|
|
|
{ |
27
|
|
|
private $minimalConfig = []; |
28
|
|
|
|
29
|
|
|
private $siteaccessConfig = []; |
30
|
|
|
|
31
|
|
|
/** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension */ |
32
|
|
|
private $extension; |
33
|
|
|
|
34
|
|
|
protected function setUp(): void |
35
|
|
|
{ |
36
|
|
|
parent::setUp(); |
37
|
|
|
|
38
|
|
|
$loader = new YamlFileLoader( |
39
|
|
|
$this->container, |
40
|
|
|
new FileLocator(__DIR__ . '/Fixtures') |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$loader->load('parameters.yml'); |
44
|
|
|
|
45
|
|
|
$this->siteaccessConfig = [ |
46
|
|
|
'siteaccess' => [ |
47
|
|
|
'default_siteaccess' => 'ezdemo_site', |
48
|
|
|
'list' => ['ezdemo_site', 'eng', 'fre', 'ezdemo_site_admin'], |
49
|
|
|
'groups' => [ |
50
|
|
|
'ezdemo_group' => ['ezdemo_site', 'eng', 'fre', 'ezdemo_site_admin'], |
51
|
|
|
'ezdemo_frontend_group' => ['ezdemo_site', 'eng', 'fre'], |
52
|
|
|
'empty_group' => [], |
53
|
|
|
], |
54
|
|
|
'match' => [ |
55
|
|
|
'URILElement' => 1, |
56
|
|
|
'Map\URI' => ['the_front' => 'ezdemo_site', 'the_back' => 'ezdemo_site_admin'], |
57
|
|
|
], |
58
|
|
|
], |
59
|
|
|
'system' => [ |
60
|
|
|
'ezdemo_site' => [], |
61
|
|
|
'eng' => [], |
62
|
|
|
'fre' => [], |
63
|
|
|
'ezdemo_site_admin' => [], |
64
|
|
|
'empty_group' => ['var_dir' => 'foo'], |
65
|
|
|
], |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
protected function getContainerExtensions(): array |
70
|
|
|
{ |
71
|
|
|
return [EzPublishCoreExtension::class => $this->getCoreExtension()]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
protected function getMinimalConfiguration(): array |
75
|
|
|
{ |
76
|
|
|
return $this->minimalConfig = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/ezpublish_minimal_no_siteaccess.yml')); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testSiteAccessConfiguration() |
80
|
|
|
{ |
81
|
|
|
$this->load($this->siteaccessConfig); |
82
|
|
|
$this->assertContainerBuilderHasParameter( |
83
|
|
|
'ezpublish.siteaccess.list', |
84
|
|
|
$this->siteaccessConfig['siteaccess']['list'] |
85
|
|
|
); |
86
|
|
|
$this->assertContainerBuilderHasParameter( |
87
|
|
|
'ezpublish.siteaccess.default', |
88
|
|
|
$this->siteaccessConfig['siteaccess']['default_siteaccess'] |
89
|
|
|
); |
90
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.groups', $this->siteaccessConfig['siteaccess']['groups']); |
91
|
|
|
|
92
|
|
|
$expectedMatchingConfig = []; |
93
|
|
|
foreach ($this->siteaccessConfig['siteaccess']['match'] as $key => $val) { |
94
|
|
|
// Value is expected to always be an array (transformed by semantic configuration parser). |
95
|
|
|
$expectedMatchingConfig[$key] = is_array($val) ? $val : ['value' => $val]; |
96
|
|
|
} |
97
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.match_config', $expectedMatchingConfig); |
98
|
|
|
$this->assertContainerBuilderHasParameter('ezsettings.empty_group.var_dir', 'foo'); |
99
|
|
|
|
100
|
|
|
$groupsBySiteaccess = []; |
101
|
|
View Code Duplication |
foreach ($this->siteaccessConfig['siteaccess']['groups'] as $groupName => $groupMembers) { |
|
|
|
|
102
|
|
|
foreach ($groupMembers as $member) { |
103
|
|
|
if (!isset($groupsBySiteaccess[$member])) { |
104
|
|
|
$groupsBySiteaccess[$member] = []; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
$groupsBySiteaccess[$member][] = $groupName; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testSiteAccessNoConfiguration() |
113
|
|
|
{ |
114
|
|
|
$this->load(); |
115
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.list', ['setup']); |
116
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.default', 'setup'); |
117
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.groups', []); |
118
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.groups_by_siteaccess', []); |
119
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.match_config', null); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function testImageMagickConfigurationBasic() |
123
|
|
|
{ |
124
|
|
View Code Duplication |
if (!isset($_ENV['imagemagickConvertPath']) || !is_executable($_ENV['imagemagickConvertPath'])) { |
|
|
|
|
125
|
|
|
$this->markTestSkipped('Missing or mis-configured Imagemagick convert path.'); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
$this->load( |
129
|
|
|
[ |
130
|
|
|
'imagemagick' => [ |
131
|
|
|
'enabled' => true, |
132
|
|
|
'path' => $_ENV['imagemagickConvertPath'], |
133
|
|
|
], |
134
|
|
|
] |
135
|
|
|
); |
136
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.image.imagemagick.enabled', true); |
137
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.image.imagemagick.executable_path', dirname($_ENV['imagemagickConvertPath'])); |
138
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.image.imagemagick.executable', basename($_ENV['imagemagickConvertPath'])); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function testImageMagickConfigurationFilters() |
142
|
|
|
{ |
143
|
|
View Code Duplication |
if (!isset($_ENV['imagemagickConvertPath']) || !is_executable($_ENV['imagemagickConvertPath'])) { |
|
|
|
|
144
|
|
|
$this->markTestSkipped('Missing or mis-configured Imagemagick convert path.'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
$customFilters = [ |
148
|
|
|
'foobar' => '-foobar', |
149
|
|
|
'wow' => '-amazing', |
150
|
|
|
]; |
151
|
|
|
$this->load( |
152
|
|
|
[ |
153
|
|
|
'imagemagick' => [ |
154
|
|
|
'enabled' => true, |
155
|
|
|
'path' => $_ENV['imagemagickConvertPath'], |
156
|
|
|
'filters' => $customFilters, |
157
|
|
|
], |
158
|
|
|
] |
159
|
|
|
); |
160
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.image.imagemagick.filters')); |
161
|
|
|
$filters = $this->container->getParameter('ezpublish.image.imagemagick.filters'); |
162
|
|
|
$this->assertArrayHasKey('foobar', $filters); |
163
|
|
|
$this->assertSame($customFilters['foobar'], $filters['foobar']); |
164
|
|
|
$this->assertArrayHasKey('wow', $filters); |
165
|
|
|
$this->assertSame($customFilters['wow'], $filters['wow']); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function testImagePlaceholderConfiguration() |
169
|
|
|
{ |
170
|
|
|
$this->load([ |
171
|
|
|
'image_placeholder' => [ |
172
|
|
|
'default' => [ |
173
|
|
|
'provider' => 'generic', |
174
|
|
|
'options' => [ |
175
|
|
|
'foo' => 'Foo', |
176
|
|
|
'bar' => 'Bar', |
177
|
|
|
], |
178
|
|
|
], |
179
|
|
|
'fancy' => [ |
180
|
|
|
'provider' => 'remote', |
181
|
|
|
], |
182
|
|
|
], |
183
|
|
|
]); |
184
|
|
|
|
185
|
|
|
$this->assertEquals([ |
186
|
|
|
'default' => [ |
187
|
|
|
'provider' => 'generic', |
188
|
|
|
'options' => [ |
189
|
|
|
'foo' => 'Foo', |
190
|
|
|
'bar' => 'Bar', |
191
|
|
|
], |
192
|
|
|
], |
193
|
|
|
'fancy' => [ |
194
|
|
|
'provider' => 'remote', |
195
|
|
|
'options' => [], |
196
|
|
|
], |
197
|
|
|
], $this->container->getParameter('image_alias.placeholder_providers')); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
public function testRoutingConfiguration() |
201
|
|
|
{ |
202
|
|
|
$this->load(); |
203
|
|
|
$this->assertContainerBuilderHasAlias('router', 'ezpublish.chain_router'); |
204
|
|
|
|
205
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.default_router.non_siteaccess_aware_routes')); |
206
|
|
|
$nonSiteaccessAwareRoutes = $this->container->getParameter('ezpublish.default_router.non_siteaccess_aware_routes'); |
207
|
|
|
// See ezpublish_minimal_no_siteaccess.yml fixture |
208
|
|
|
$this->assertContains('foo_route', $nonSiteaccessAwareRoutes); |
209
|
|
|
$this->assertContains('my_prefix_', $nonSiteaccessAwareRoutes); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @dataProvider cacheConfigurationProvider |
214
|
|
|
* |
215
|
|
|
* @param array $customCacheConfig |
216
|
|
|
* @param string $expectedPurgeType |
217
|
|
|
*/ |
218
|
|
|
public function testCacheConfiguration(array $customCacheConfig, $expectedPurgeType) |
219
|
|
|
{ |
220
|
|
|
$this->load($customCacheConfig); |
221
|
|
|
|
222
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.http_cache.purge_type', $expectedPurgeType); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function cacheConfigurationProvider() |
226
|
|
|
{ |
227
|
|
|
return [ |
228
|
|
|
[[], 'local'], |
229
|
|
|
[ |
230
|
|
|
[ |
231
|
|
|
'http_cache' => ['purge_type' => 'local'], |
232
|
|
|
], |
233
|
|
|
'local', |
234
|
|
|
], |
235
|
|
|
[ |
236
|
|
|
[ |
237
|
|
|
'http_cache' => ['purge_type' => 'multiple_http'], |
238
|
|
|
], |
239
|
|
|
'http', |
240
|
|
|
], |
241
|
|
|
[ |
242
|
|
|
[ |
243
|
|
|
'http_cache' => ['purge_type' => 'single_http'], |
244
|
|
|
], |
245
|
|
|
'http', |
246
|
|
|
], |
247
|
|
|
[ |
248
|
|
|
[ |
249
|
|
|
'http_cache' => ['purge_type' => 'http'], |
250
|
|
|
], |
251
|
|
|
'http', |
252
|
|
|
], |
253
|
|
|
]; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public function testCacheConfigurationCustomPurgeService() |
257
|
|
|
{ |
258
|
|
|
$serviceId = 'foobar'; |
259
|
|
|
$this->setDefinition($serviceId, new Definition()); |
260
|
|
|
$this->load( |
261
|
|
|
[ |
262
|
|
|
'http_cache' => ['purge_type' => 'foobar', 'timeout' => 12], |
263
|
|
|
] |
264
|
|
|
); |
265
|
|
|
|
266
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.http_cache.purge_type', 'foobar'); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function testLocaleConfiguration() |
270
|
|
|
{ |
271
|
|
|
$this->load(['locale_conversion' => ['foo' => 'bar']]); |
272
|
|
|
$conversionMap = $this->container->getParameter('ezpublish.locale.conversion_map'); |
273
|
|
|
$this->assertArrayHasKey('foo', $conversionMap); |
274
|
|
|
$this->assertSame('bar', $conversionMap['foo']); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
public function testRepositoriesConfiguration() |
278
|
|
|
{ |
279
|
|
|
$repositories = [ |
280
|
|
|
'main' => [ |
281
|
|
|
'storage' => [ |
282
|
|
|
'engine' => 'legacy', |
283
|
|
|
'connection' => 'default', |
284
|
|
|
], |
285
|
|
|
'search' => [ |
286
|
|
|
'engine' => 'legacy', |
287
|
|
|
'connection' => 'blabla', |
288
|
|
|
], |
289
|
|
|
'fields_groups' => [ |
290
|
|
|
'list' => ['content', 'metadata'], |
291
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
292
|
|
|
], |
293
|
|
|
'options' => [ |
294
|
|
|
'default_version_archive_limit' => 5, |
295
|
|
|
], |
296
|
|
|
], |
297
|
|
|
'foo' => [ |
298
|
|
|
'storage' => [ |
299
|
|
|
'engine' => 'sqlng', |
300
|
|
|
'connection' => 'default', |
301
|
|
|
], |
302
|
|
|
'search' => [ |
303
|
|
|
'engine' => 'solr', |
304
|
|
|
'connection' => 'lalala', |
305
|
|
|
], |
306
|
|
|
'fields_groups' => [ |
307
|
|
|
'list' => ['content', 'metadata'], |
308
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
309
|
|
|
], |
310
|
|
|
'options' => [ |
311
|
|
|
'default_version_archive_limit' => 5, |
312
|
|
|
], |
313
|
|
|
], |
314
|
|
|
]; |
315
|
|
|
$this->load(['repositories' => $repositories]); |
316
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
317
|
|
|
|
318
|
|
|
foreach ($repositories as &$repositoryConfig) { |
319
|
|
|
$repositoryConfig['storage']['config'] = []; |
320
|
|
|
$repositoryConfig['search']['config'] = []; |
321
|
|
|
} |
322
|
|
|
$this->assertSame($repositories, $this->container->getParameter('ezpublish.repositories')); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @dataProvider repositoriesConfigurationFieldGroupsProvider |
327
|
|
|
*/ |
328
|
|
|
public function testRepositoriesConfigurationFieldGroups($repositories, $expectedRepositories) |
329
|
|
|
{ |
330
|
|
|
$this->load(['repositories' => $repositories]); |
331
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
332
|
|
|
|
333
|
|
|
$repositoriesPar = $this->container->getParameter('ezpublish.repositories'); |
334
|
|
|
$this->assertEquals(count($repositories), count($repositoriesPar)); |
335
|
|
|
|
336
|
|
|
foreach ($repositoriesPar as $key => $repo) { |
337
|
|
|
$this->assertArrayHasKey($key, $expectedRepositories); |
338
|
|
|
$this->assertArrayHasKey('fields_groups', $repo); |
339
|
|
|
$this->assertEqualsCanonicalizing($expectedRepositories[$key]['fields_groups'], $repo['fields_groups'], 'Invalid fields groups element'); |
340
|
|
|
} |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
public function repositoriesConfigurationFieldGroupsProvider() |
344
|
|
|
{ |
345
|
|
|
return [ |
346
|
|
|
//empty config |
347
|
|
|
[ |
348
|
|
|
['main' => null], |
349
|
|
|
['main' => [ |
350
|
|
|
'fields_groups' => [ |
351
|
|
|
'list' => ['content', 'metadata'], |
352
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
353
|
|
|
], |
354
|
|
|
], |
355
|
|
|
], |
356
|
|
|
], |
357
|
|
|
//single item with custom fields |
358
|
|
|
[ |
359
|
|
|
['foo' => [ |
360
|
|
|
'fields_groups' => [ |
361
|
|
|
'list' => ['bar', 'baz', 'john'], |
362
|
|
|
'default' => 'bar', |
363
|
|
|
], |
364
|
|
|
], |
365
|
|
|
], |
366
|
|
|
['foo' => [ |
367
|
|
|
'fields_groups' => [ |
368
|
|
|
'list' => ['bar', 'baz', 'john'], |
369
|
|
|
'default' => 'bar', |
370
|
|
|
], |
371
|
|
|
], |
372
|
|
|
], |
373
|
|
|
], |
374
|
|
|
//mixed item with custom config and empty item |
375
|
|
|
[ |
376
|
|
|
[ |
377
|
|
|
'foo' => [ |
378
|
|
|
'fields_groups' => [ |
379
|
|
|
'list' => ['bar', 'baz', 'john', 'doe'], |
380
|
|
|
'default' => 'bar', |
381
|
|
|
], |
382
|
|
|
], |
383
|
|
|
'anotherone' => null, |
384
|
|
|
], |
385
|
|
|
[ |
386
|
|
|
'foo' => [ |
387
|
|
|
'fields_groups' => [ |
388
|
|
|
'list' => ['bar', 'baz', 'john', 'doe'], |
389
|
|
|
'default' => 'bar', |
390
|
|
|
], |
391
|
|
|
], |
392
|
|
|
'anotherone' => [ |
393
|
|
|
'fields_groups' => [ |
394
|
|
|
'list' => ['content', 'metadata'], |
395
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
396
|
|
|
], |
397
|
|
|
], |
398
|
|
|
], |
399
|
|
|
], |
400
|
|
|
//items with only one field configured |
401
|
|
|
[ |
402
|
|
|
[ |
403
|
|
|
'foo' => [ |
404
|
|
|
'fields_groups' => [ |
405
|
|
|
'list' => ['bar', 'baz', 'john'], |
406
|
|
|
], |
407
|
|
|
], |
408
|
|
|
'bar' => [ |
409
|
|
|
'fields_groups' => [ |
410
|
|
|
'default' => 'metadata', |
411
|
|
|
], |
412
|
|
|
], |
413
|
|
|
], |
414
|
|
|
[ |
415
|
|
|
'foo' => [ |
416
|
|
|
'fields_groups' => [ |
417
|
|
|
'list' => ['bar', 'baz', 'john'], |
418
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
419
|
|
|
], |
420
|
|
|
], |
421
|
|
|
'bar' => [ |
422
|
|
|
'fields_groups' => [ |
423
|
|
|
'list' => ['content', 'metadata'], |
424
|
|
|
'default' => 'metadata', |
425
|
|
|
], |
426
|
|
|
], |
427
|
|
|
], |
428
|
|
|
], |
429
|
|
|
//two different repositories |
430
|
|
|
[ |
431
|
|
|
[ |
432
|
|
|
'foo' => [ |
433
|
|
|
'fields_groups' => [ |
434
|
|
|
'list' => ['bar', 'baz', 'john', 'doe'], |
435
|
|
|
'default' => 'bar', |
436
|
|
|
], |
437
|
|
|
], |
438
|
|
|
'bar' => [ |
439
|
|
|
'fields_groups' => [ |
440
|
|
|
'list' => ['lorem', 'ipsum'], |
441
|
|
|
'default' => 'lorem', |
442
|
|
|
], |
443
|
|
|
], |
444
|
|
|
], |
445
|
|
|
[ |
446
|
|
|
'foo' => [ |
447
|
|
|
'fields_groups' => [ |
448
|
|
|
'list' => ['bar', 'baz', 'john', 'doe'], |
449
|
|
|
'default' => 'bar', |
450
|
|
|
], |
451
|
|
|
], |
452
|
|
|
'bar' => [ |
453
|
|
|
'fields_groups' => [ |
454
|
|
|
'list' => ['lorem', 'ipsum'], |
455
|
|
|
'default' => 'lorem', |
456
|
|
|
], |
457
|
|
|
], |
458
|
|
|
], |
459
|
|
|
], |
460
|
|
|
]; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
public function testRepositoriesConfigurationEmpty() |
464
|
|
|
{ |
465
|
|
|
$repositories = [ |
466
|
|
|
'main' => null, |
467
|
|
|
]; |
468
|
|
|
$expectedRepositories = [ |
469
|
|
|
'main' => [ |
470
|
|
|
'storage' => [ |
471
|
|
|
'engine' => '%ezpublish.api.storage_engine.default%', |
472
|
|
|
'connection' => null, |
473
|
|
|
'config' => [], |
474
|
|
|
], |
475
|
|
|
'search' => [ |
476
|
|
|
'engine' => '%ezpublish.api.search_engine.default%', |
477
|
|
|
'connection' => null, |
478
|
|
|
'config' => [], |
479
|
|
|
], |
480
|
|
|
'fields_groups' => [ |
481
|
|
|
'list' => ['content', 'metadata'], |
482
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
483
|
|
|
], |
484
|
|
|
'options' => [ |
485
|
|
|
'default_version_archive_limit' => 5, |
486
|
|
|
], |
487
|
|
|
], |
488
|
|
|
]; |
489
|
|
|
$this->load(['repositories' => $repositories]); |
490
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
491
|
|
|
|
492
|
|
|
$this->assertSame( |
493
|
|
|
$expectedRepositories, |
494
|
|
|
$this->container->getParameter('ezpublish.repositories') |
495
|
|
|
); |
496
|
|
|
} |
497
|
|
|
|
498
|
|
View Code Duplication |
public function testRepositoriesConfigurationStorageEmpty() |
499
|
|
|
{ |
500
|
|
|
$repositories = [ |
501
|
|
|
'main' => [ |
502
|
|
|
'search' => [ |
503
|
|
|
'engine' => 'fantasticfind', |
504
|
|
|
'connection' => 'french', |
505
|
|
|
], |
506
|
|
|
], |
507
|
|
|
]; |
508
|
|
|
$expectedRepositories = [ |
509
|
|
|
'main' => [ |
510
|
|
|
'search' => [ |
511
|
|
|
'engine' => 'fantasticfind', |
512
|
|
|
'connection' => 'french', |
513
|
|
|
'config' => [], |
514
|
|
|
], |
515
|
|
|
'storage' => [ |
516
|
|
|
'engine' => '%ezpublish.api.storage_engine.default%', |
517
|
|
|
'connection' => null, |
518
|
|
|
'config' => [], |
519
|
|
|
], |
520
|
|
|
'fields_groups' => [ |
521
|
|
|
'list' => ['content', 'metadata'], |
522
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
523
|
|
|
], |
524
|
|
|
'options' => [ |
525
|
|
|
'default_version_archive_limit' => 5, |
526
|
|
|
], |
527
|
|
|
], |
528
|
|
|
]; |
529
|
|
|
$this->load(['repositories' => $repositories]); |
530
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
531
|
|
|
|
532
|
|
|
$this->assertSame( |
533
|
|
|
$expectedRepositories, |
534
|
|
|
$this->container->getParameter('ezpublish.repositories') |
535
|
|
|
); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
View Code Duplication |
public function testRepositoriesConfigurationSearchEmpty() |
539
|
|
|
{ |
540
|
|
|
$repositories = [ |
541
|
|
|
'main' => [ |
542
|
|
|
'storage' => [ |
543
|
|
|
'engine' => 'persistentprudence', |
544
|
|
|
'connection' => 'yes', |
545
|
|
|
], |
546
|
|
|
], |
547
|
|
|
]; |
548
|
|
|
$expectedRepositories = [ |
549
|
|
|
'main' => [ |
550
|
|
|
'storage' => [ |
551
|
|
|
'engine' => 'persistentprudence', |
552
|
|
|
'connection' => 'yes', |
553
|
|
|
'config' => [], |
554
|
|
|
], |
555
|
|
|
'search' => [ |
556
|
|
|
'engine' => '%ezpublish.api.search_engine.default%', |
557
|
|
|
'connection' => null, |
558
|
|
|
'config' => [], |
559
|
|
|
], |
560
|
|
|
'fields_groups' => [ |
561
|
|
|
'list' => ['content', 'metadata'], |
562
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
563
|
|
|
], |
564
|
|
|
'options' => [ |
565
|
|
|
'default_version_archive_limit' => 5, |
566
|
|
|
], |
567
|
|
|
], |
568
|
|
|
]; |
569
|
|
|
$this->load(['repositories' => $repositories]); |
570
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
571
|
|
|
|
572
|
|
|
$this->assertSame( |
573
|
|
|
$expectedRepositories, |
574
|
|
|
$this->container->getParameter('ezpublish.repositories') |
575
|
|
|
); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
public function testRepositoriesConfigurationCompatibility() |
579
|
|
|
{ |
580
|
|
|
$repositories = [ |
581
|
|
|
'main' => [ |
582
|
|
|
'engine' => 'legacy', |
583
|
|
|
'connection' => 'default', |
584
|
|
|
'search' => [ |
585
|
|
|
'engine' => 'legacy', |
586
|
|
|
'connection' => 'blabla', |
587
|
|
|
], |
588
|
|
|
], |
589
|
|
|
'foo' => [ |
590
|
|
|
'engine' => 'sqlng', |
591
|
|
|
'connection' => 'default', |
592
|
|
|
'search' => [ |
593
|
|
|
'engine' => 'solr', |
594
|
|
|
'connection' => 'lalala', |
595
|
|
|
], |
596
|
|
|
], |
597
|
|
|
]; |
598
|
|
|
$expectedRepositories = [ |
599
|
|
|
'main' => [ |
600
|
|
|
'search' => [ |
601
|
|
|
'engine' => 'legacy', |
602
|
|
|
'connection' => 'blabla', |
603
|
|
|
'config' => [], |
604
|
|
|
], |
605
|
|
|
'storage' => [ |
606
|
|
|
'engine' => 'legacy', |
607
|
|
|
'connection' => 'default', |
608
|
|
|
'config' => [], |
609
|
|
|
], |
610
|
|
|
'fields_groups' => [ |
611
|
|
|
'list' => ['content', 'metadata'], |
612
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
613
|
|
|
], |
614
|
|
|
'options' => [ |
615
|
|
|
'default_version_archive_limit' => 5, |
616
|
|
|
], |
617
|
|
|
], |
618
|
|
|
'foo' => [ |
619
|
|
|
'search' => [ |
620
|
|
|
'engine' => 'solr', |
621
|
|
|
'connection' => 'lalala', |
622
|
|
|
'config' => [], |
623
|
|
|
], |
624
|
|
|
'storage' => [ |
625
|
|
|
'engine' => 'sqlng', |
626
|
|
|
'connection' => 'default', |
627
|
|
|
'config' => [], |
628
|
|
|
], |
629
|
|
|
'fields_groups' => [ |
630
|
|
|
'list' => ['content', 'metadata'], |
631
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
632
|
|
|
], |
633
|
|
|
'options' => [ |
634
|
|
|
'default_version_archive_limit' => 5, |
635
|
|
|
], |
636
|
|
|
], |
637
|
|
|
]; |
638
|
|
|
$this->load(['repositories' => $repositories]); |
639
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
640
|
|
|
|
641
|
|
|
$this->assertSame( |
642
|
|
|
$expectedRepositories, |
643
|
|
|
$this->container->getParameter('ezpublish.repositories') |
644
|
|
|
); |
645
|
|
|
} |
646
|
|
|
|
647
|
|
View Code Duplication |
public function testRepositoriesConfigurationCompatibility2() |
648
|
|
|
{ |
649
|
|
|
$repositories = [ |
650
|
|
|
'main' => [ |
651
|
|
|
'engine' => 'legacy', |
652
|
|
|
'connection' => 'default', |
653
|
|
|
], |
654
|
|
|
]; |
655
|
|
|
$expectedRepositories = [ |
656
|
|
|
'main' => [ |
657
|
|
|
'storage' => [ |
658
|
|
|
'engine' => 'legacy', |
659
|
|
|
'connection' => 'default', |
660
|
|
|
'config' => [], |
661
|
|
|
], |
662
|
|
|
'search' => [ |
663
|
|
|
'engine' => '%ezpublish.api.search_engine.default%', |
664
|
|
|
'connection' => null, |
665
|
|
|
'config' => [], |
666
|
|
|
], |
667
|
|
|
'fields_groups' => [ |
668
|
|
|
'list' => ['content', 'metadata'], |
669
|
|
|
'default' => '%ezsettings.default.content.field_groups.default%', |
670
|
|
|
], |
671
|
|
|
'options' => [ |
672
|
|
|
'default_version_archive_limit' => 5, |
673
|
|
|
], |
674
|
|
|
], |
675
|
|
|
]; |
676
|
|
|
$this->load(['repositories' => $repositories]); |
677
|
|
|
$this->assertTrue($this->container->hasParameter('ezpublish.repositories')); |
678
|
|
|
|
679
|
|
|
$this->assertSame( |
680
|
|
|
$expectedRepositories, |
681
|
|
|
$this->container->getParameter('ezpublish.repositories') |
682
|
|
|
); |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
public function testRegisteredPolicies() |
686
|
|
|
{ |
687
|
|
|
$this->load(); |
688
|
|
|
self::assertContainerBuilderHasParameter('ezpublish.api.role.policy_map'); |
689
|
|
|
$previousPolicyMap = $this->container->getParameter('ezpublish.api.role.policy_map'); |
690
|
|
|
|
691
|
|
|
$policies1 = [ |
692
|
|
|
'custom_module' => [ |
693
|
|
|
'custom_function_1' => null, |
694
|
|
|
'custom_function_2' => ['CustomLimitation'], |
695
|
|
|
], |
696
|
|
|
'helloworld' => [ |
697
|
|
|
'foo' => ['bar'], |
698
|
|
|
'baz' => null, |
699
|
|
|
], |
700
|
|
|
]; |
701
|
|
|
$this->extension->addPolicyProvider(new StubPolicyProvider($policies1)); |
702
|
|
|
|
703
|
|
|
$policies2 = [ |
704
|
|
|
'custom_module2' => [ |
705
|
|
|
'custom_function_3' => null, |
706
|
|
|
'custom_function_4' => ['CustomLimitation2', 'CustomLimitation3'], |
707
|
|
|
], |
708
|
|
|
'helloworld' => [ |
709
|
|
|
'foo' => ['additional_limitation'], |
710
|
|
|
'some' => ['thingy', 'thing', 'but', 'wait'], |
711
|
|
|
], |
712
|
|
|
]; |
713
|
|
|
$this->extension->addPolicyProvider(new StubPolicyProvider($policies2)); |
714
|
|
|
|
715
|
|
|
$expectedPolicies = [ |
716
|
|
|
'custom_module' => [ |
717
|
|
|
'custom_function_1' => [], |
718
|
|
|
'custom_function_2' => ['CustomLimitation' => true], |
719
|
|
|
], |
720
|
|
|
'helloworld' => [ |
721
|
|
|
'foo' => ['bar' => true, 'additional_limitation' => true], |
722
|
|
|
'baz' => [], |
723
|
|
|
'some' => ['thingy' => true, 'thing' => true, 'but' => true, 'wait' => true], |
724
|
|
|
], |
725
|
|
|
'custom_module2' => [ |
726
|
|
|
'custom_function_3' => [], |
727
|
|
|
'custom_function_4' => ['CustomLimitation2' => true, 'CustomLimitation3' => true], |
728
|
|
|
], |
729
|
|
|
]; |
730
|
|
|
|
731
|
|
|
$this->load(); |
732
|
|
|
self::assertContainerBuilderHasParameter('ezpublish.api.role.policy_map'); |
733
|
|
|
$expectedPolicies = array_merge_recursive($expectedPolicies, $previousPolicyMap); |
734
|
|
|
self::assertEquals($expectedPolicies, $this->container->getParameter('ezpublish.api.role.policy_map')); |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
public function testUrlAliasConfiguration() |
738
|
|
|
{ |
739
|
|
|
$configuration = [ |
740
|
|
|
'transformation' => 'urlalias_lowercase', |
741
|
|
|
'separator' => 'dash', |
742
|
|
|
'transformation_groups' => [ |
743
|
|
|
'urlalias' => [ |
744
|
|
|
'commands' => [ |
745
|
|
|
'ascii_lowercase', |
746
|
|
|
'cyrillic_lowercase', |
747
|
|
|
], |
748
|
|
|
'cleanup_method' => 'url_cleanup', |
749
|
|
|
], |
750
|
|
|
'urlalias_compact' => [ |
751
|
|
|
'commands' => [ |
752
|
|
|
'greek_normalize', |
753
|
|
|
'exta_lowercase', |
754
|
|
|
], |
755
|
|
|
'cleanup_method' => 'compact_cleanup', |
756
|
|
|
], |
757
|
|
|
], |
758
|
|
|
]; |
759
|
|
|
$this->load([ |
760
|
|
|
'url_alias' => [ |
761
|
|
|
'slug_converter' => $configuration, |
762
|
|
|
], |
763
|
|
|
]); |
764
|
|
|
$parsedConfig = $this->container->getParameter('ezpublish.url_alias.slug_converter'); |
765
|
|
|
$this->assertSame( |
766
|
|
|
$configuration, |
767
|
|
|
$parsedConfig |
768
|
|
|
); |
769
|
|
|
} |
770
|
|
|
|
771
|
|
|
/** |
772
|
|
|
* Test automatic configuration of services implementing QueryType interface. |
773
|
|
|
* |
774
|
|
|
* @see \eZ\Publish\Core\QueryType\QueryType |
775
|
|
|
*/ |
776
|
|
|
public function testQueryTypeAutomaticConfiguration(): void |
777
|
|
|
{ |
778
|
|
|
$definition = new Definition(TestQueryType::class); |
779
|
|
|
$definition->setAutoconfigured(true); |
780
|
|
|
$this->setDefinition(TestQueryType::class, $definition); |
781
|
|
|
|
782
|
|
|
$this->load(); |
783
|
|
|
|
784
|
|
|
$this->compileCoreContainer(); |
785
|
|
|
|
786
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithTag( |
787
|
|
|
TestQueryType::class, |
788
|
|
|
QueryTypePass::QUERY_TYPE_SERVICE_TAG |
789
|
|
|
); |
790
|
|
|
} |
791
|
|
|
|
792
|
|
|
/** |
793
|
|
|
* Prepare Core Container for compilation by mocking required parameters and compile it. |
794
|
|
|
*/ |
795
|
|
|
private function compileCoreContainer(): void |
796
|
|
|
{ |
797
|
|
|
$this->disableCheckExceptionOnInvalidReferenceBehaviorPass(); |
798
|
|
|
$this->container->setParameter('webroot_dir', __DIR__); |
799
|
|
|
$this->container->setParameter('kernel.project_dir', __DIR__); |
800
|
|
|
$this->container->setParameter('kernel.cache_dir', __DIR__ . '/cache'); |
801
|
|
|
$this->container->setParameter('kernel.debug', false); |
802
|
|
|
$this->compile(); |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
final public function disableCheckExceptionOnInvalidReferenceBehaviorPass(): void |
806
|
|
|
{ |
807
|
|
|
$compilerPassConfig = $this->container->getCompilerPassConfig(); |
808
|
|
|
$compilerPassConfig->setAfterRemovingPasses( |
809
|
|
|
array_filter( |
810
|
|
|
$compilerPassConfig->getAfterRemovingPasses(), |
811
|
|
|
static function (CompilerPassInterface $pass) { |
812
|
|
|
return !($pass instanceof CheckExceptionOnInvalidReferenceBehaviorPass); |
813
|
|
|
} |
814
|
|
|
) |
815
|
|
|
); |
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
protected function getCoreExtension(): EzPublishCoreExtension |
819
|
|
|
{ |
820
|
|
|
if (null !== $this->extension) { |
821
|
|
|
return $this->extension; |
822
|
|
|
} |
823
|
|
|
|
824
|
|
|
$this->extension = new EzPublishCoreExtension([new Common(), new Content()]); |
825
|
|
|
|
826
|
|
|
return $this->extension; |
827
|
|
|
} |
828
|
|
|
} |
829
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..