1 | <?php |
||
22 | abstract class AbstractElasticsearchTestCase extends WebTestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var Manager[] Holds used managers. |
||
26 | */ |
||
27 | private $managers = []; |
||
28 | |||
29 | /** |
||
30 | * @var ContainerInterface |
||
31 | */ |
||
32 | private $container; |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | protected function setUp() |
||
44 | |||
45 | /** |
||
46 | * Can be overwritten in child class to populate elasticsearch index with the data. |
||
47 | * |
||
48 | * Example: |
||
49 | * "manager_name" => |
||
50 | * [ |
||
51 | * 'type_name' => [ |
||
52 | * [ |
||
53 | * '_id' => 1, |
||
54 | * 'title' => 'foo', |
||
55 | * ], |
||
56 | * [ |
||
57 | * '_id' => 2, |
||
58 | * 'title' => 'bar', |
||
59 | * ] |
||
60 | * ] |
||
61 | * ] |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | protected function getDataArray() |
||
69 | |||
70 | /** |
||
71 | * Ignores versions specified. |
||
72 | * |
||
73 | * Returns two dimensional array, first item in sub array is version to ignore, second is comparator, |
||
74 | * last test name. If no test name is provided it will be used on all test class. |
||
75 | * |
||
76 | * Comparator types can be found in `version_compare` documentation. |
||
77 | * |
||
78 | * Example: [ |
||
79 | * ['1.2.7', '<='], |
||
80 | * ['1.2.9', '==', 'testSmth'] |
||
81 | * ] |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | protected function getIgnoredVersions() |
||
89 | |||
90 | /** |
||
91 | * Ignores version specified. |
||
92 | * |
||
93 | * @param Manager $manager |
||
94 | */ |
||
95 | private function ignoreVersions(Manager $manager) |
||
116 | |||
117 | /** |
||
118 | * Removes manager from local cache and drops its index. |
||
119 | * |
||
120 | * @param string $name |
||
121 | */ |
||
122 | protected function removeManager($name) |
||
129 | |||
130 | /** |
||
131 | * Populates elasticsearch with data. |
||
132 | * |
||
133 | * @param Manager $manager |
||
134 | * @param array $data |
||
135 | */ |
||
136 | private function populateElasticsearchWithData($manager, array $data) |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | protected function tearDown() |
||
164 | |||
165 | /** |
||
166 | * Returns service container. |
||
167 | * |
||
168 | * @param bool $reinitialize Force kernel reinitialization. |
||
169 | * @param array $kernelOptions Options used passed to kernel if it needs to be initialized. |
||
170 | * |
||
171 | * @return ContainerInterface |
||
172 | */ |
||
173 | protected function getContainer($reinitialize = false, $kernelOptions = []) |
||
182 | |||
183 | /** |
||
184 | * Returns manager instance with injected connection if does not exist creates new one. |
||
185 | * |
||
186 | * @param string $name Manager name |
||
187 | * |
||
188 | * @return Manager |
||
189 | * |
||
190 | * @throws \LogicException |
||
191 | */ |
||
192 | protected function getManager($name = 'default') |
||
220 | } |
||
221 |