@@ 75-117 (lines=43) @@ | ||
72 | return $indices; |
|
73 | } |
|
74 | ||
75 | public function testIndexWithIndexAndType() |
|
76 | { |
|
77 | $client = $this->newClientExpectingBulk( |
|
78 | [ |
|
79 | 'body' => |
|
80 | [ |
|
81 | [ |
|
82 | 'index' => [ |
|
83 | '_index' => 'my_index', |
|
84 | '_type' => 'my_type', |
|
85 | '_id' => 'my_id', |
|
86 | ] |
|
87 | ], |
|
88 | [ |
|
89 | 'foo' => 'bar', |
|
90 | ] |
|
91 | ] |
|
92 | ] |
|
93 | ); |
|
94 | ||
95 | $provider = $this->getMockForAbstractClass(BulkDataProvider::class); |
|
96 | $provider |
|
97 | ->expects($this->once()) |
|
98 | ->method('populate') |
|
99 | ->will( |
|
100 | $this->returnCallback( |
|
101 | function () use ($provider) { |
|
102 | $provider->index( |
|
103 | 'my_id', |
|
104 | ['foo' => 'bar'] |
|
105 | ); |
|
106 | } |
|
107 | ) |
|
108 | ) |
|
109 | ; |
|
110 | ||
111 | $provider->run( |
|
112 | $client, |
|
113 | 'my_index', |
|
114 | 'my_type', |
|
115 | $this->getMock(EventDispatcherInterface::class) |
|
116 | ); |
|
117 | } |
|
118 | ||
119 | private function newClientExpectingBulk($content) |
|
120 | { |
|
@@ 213-252 (lines=40) @@ | ||
210 | ); |
|
211 | } |
|
212 | ||
213 | public function testCreate() |
|
214 | { |
|
215 | $client = $this->newClientExpectingBulk( |
|
216 | [ |
|
217 | 'body' => |
|
218 | [ |
|
219 | [ |
|
220 | 'create' => [ |
|
221 | '_index' => 'my_index', |
|
222 | '_type' => 'my_type', |
|
223 | '_id' => 'my_id', |
|
224 | ] |
|
225 | ], |
|
226 | [ |
|
227 | 'foo' => 'bar', |
|
228 | ] |
|
229 | ] |
|
230 | ] |
|
231 | ); |
|
232 | ||
233 | $provider = $this->getMockForAbstractClass(BulkDataProvider::class); |
|
234 | $provider |
|
235 | ->expects($this->once()) |
|
236 | ->method('populate') |
|
237 | ->will( |
|
238 | $this->returnCallback( |
|
239 | function () use ($provider) { |
|
240 | $provider->create('my_id', ['foo' => 'bar']); |
|
241 | } |
|
242 | ) |
|
243 | ) |
|
244 | ; |
|
245 | ||
246 | $provider->run( |
|
247 | $client, |
|
248 | 'my_index', |
|
249 | 'my_type', |
|
250 | $this->getMock(EventDispatcherInterface::class) |
|
251 | ); |
|
252 | } |
|
253 | ||
254 | public function testUpdate() |
|
255 | { |
|
@@ 254-293 (lines=40) @@ | ||
251 | ); |
|
252 | } |
|
253 | ||
254 | public function testUpdate() |
|
255 | { |
|
256 | $client = $this->newClientExpectingBulk( |
|
257 | [ |
|
258 | 'body' => |
|
259 | [ |
|
260 | [ |
|
261 | 'update' => [ |
|
262 | '_index' => 'my_index', |
|
263 | '_type' => 'my_type', |
|
264 | '_id' => 'my_id', |
|
265 | ] |
|
266 | ], |
|
267 | [ |
|
268 | 'foo' => 'bar', |
|
269 | ] |
|
270 | ] |
|
271 | ] |
|
272 | ); |
|
273 | ||
274 | $provider = $this->getMockForAbstractClass(BulkDataProvider::class); |
|
275 | $provider |
|
276 | ->expects($this->once()) |
|
277 | ->method('populate') |
|
278 | ->will( |
|
279 | $this->returnCallback( |
|
280 | function () use ($provider) { |
|
281 | $provider->update('my_id', ['foo' => 'bar']); |
|
282 | } |
|
283 | ) |
|
284 | ) |
|
285 | ; |
|
286 | ||
287 | $provider->run( |
|
288 | $client, |
|
289 | 'my_index', |
|
290 | 'my_type', |
|
291 | $this->getMock(EventDispatcherInterface::class) |
|
292 | ); |
|
293 | } |
|
294 | } |
|
295 |