-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathConfigurationTest.php
More file actions
108 lines (102 loc) · 3.95 KB
/
ConfigurationTest.php
File metadata and controls
108 lines (102 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Algolia\SearchBundle\TestCase;
use Algolia\SearchBundle\BaseTest;
use Algolia\SearchBundle\DependencyInjection\Configuration;
class ConfigurationTest extends BaseTest
{
/**
* @dataProvider dataTestConfigurationTree
*
* @param mixed $inputConfig
* @param mixed $expectedConfig
*/
public function testConfigurationTree($inputConfig, $expectedConfig)
{
$configuration = new Configuration();
$node = $configuration->getConfigTreeBuilder()
->buildTree();
$normalizedConfig = $node->normalize($inputConfig);
$finalizedConfig = $node->finalize($normalizedConfig);
$this->assertEquals($expectedConfig, $finalizedConfig);
}
public function dataTestConfigurationTree()
{
return [
'test empty config for default value' => [
[],
[
"prefix" => null,
"nbResults" => 20,
"batchSize" => 500,
'serializer' => 'serializer',
"settingsDirectory" => null,
"doctrineSubscribedEvents" => ["postPersist", "postUpdate", "preRemove"],
"indices" => [],
]
],
'Simple config' => [
[
"prefix" => "sf_",
"nbResults" => 40,
"batchSize" => 100,
],[
"prefix" => "sf_",
"nbResults" => 40,
"batchSize" => 100,
'serializer' => 'serializer',
"settingsDirectory" => null,
"doctrineSubscribedEvents" => ["postPersist", "postUpdate", "preRemove"],
"indices" => [],
]
],
'Index config' => [
[
"prefix" => "sf_",
"indices" => [
['name' => 'posts', 'class' => 'App\Entity\Post', 'index_if' => null],
[
'name' => 'tags',
'class' => 'App\Entity\Tag',
'enable_serializer_groups' => true,
'index_if' => null,
],
[
'name' => 'comments',
'class' => 'App\Entity\Comment',
'enable_serializer_groups' => true,
'serializer_groups' => ['foo', 'bar'],
'index_if' => null,
],
],
],[
"prefix" => "sf_",
"nbResults" => 20,
"batchSize" => 500,
'serializer' => 'serializer',
"settingsDirectory" => null,
"doctrineSubscribedEvents" => ["postPersist", "postUpdate", "preRemove"],
"indices" => [
'posts' => [
'class' => 'App\Entity\Post',
'enable_serializer_groups' => false,
'serializer_groups' => ['searchable'],
'index_if' => null,
],
'tags' => [
'class' => 'App\Entity\Tag',
'enable_serializer_groups' => true,
'serializer_groups' => ['searchable'],
'index_if' => null,
],
'comments' => [
'class' => 'App\Entity\Comment',
'enable_serializer_groups' => true,
'serializer_groups' => ['foo', 'bar'],
'index_if' => null,
],
],
]
],
];
}
}