@@ -86,11 +86,13 @@ public function testIndexCannotBeNullForDelete()
86
86
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
87
87
$ this ->expectExceptionMessage ('index cannot be null. ' );
88
88
89
- $ client ->delete ([
89
+ $ client ->delete (
90
+ [
90
91
'index ' => null ,
91
92
'type ' => 'test ' ,
92
93
'id ' => 'test '
93
- ]);
94
+ ]
95
+ );
94
96
}
95
97
96
98
public function testTypeCannotBeNullForDelete ()
@@ -100,11 +102,13 @@ public function testTypeCannotBeNullForDelete()
100
102
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
101
103
$ this ->expectExceptionMessage ('type cannot be null. ' );
102
104
103
- $ client ->delete ([
105
+ $ client ->delete (
106
+ [
104
107
'index ' => 'test ' ,
105
108
'type ' => null ,
106
109
'id ' => 'test '
107
- ]);
110
+ ]
111
+ );
108
112
}
109
113
110
114
public function testIdCannotBeNullForDelete ()
@@ -114,11 +118,13 @@ public function testIdCannotBeNullForDelete()
114
118
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
115
119
$ this ->expectExceptionMessage ('id cannot be null. ' );
116
120
117
- $ client ->delete ([
121
+ $ client ->delete (
122
+ [
118
123
'index ' => 'test ' ,
119
124
'type ' => 'test ' ,
120
125
'id ' => null
121
- ]);
126
+ ]
127
+ );
122
128
}
123
129
124
130
public function testIndexCannotBeEmptyStringForDelete ()
@@ -128,11 +134,13 @@ public function testIndexCannotBeEmptyStringForDelete()
128
134
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
129
135
$ this ->expectExceptionMessage ('index cannot be an empty string ' );
130
136
131
- $ client ->delete ([
137
+ $ client ->delete (
138
+ [
132
139
'index ' => '' ,
133
140
'type ' => 'test ' ,
134
141
'id ' => 'test '
135
- ]);
142
+ ]
143
+ );
136
144
}
137
145
138
146
public function testTypeCannotBeEmptyStringForDelete ()
@@ -142,11 +150,13 @@ public function testTypeCannotBeEmptyStringForDelete()
142
150
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
143
151
$ this ->expectExceptionMessage ('type cannot be an empty string ' );
144
152
145
- $ client ->delete ([
153
+ $ client ->delete (
154
+ [
146
155
'index ' => 'test ' ,
147
156
'type ' => '' ,
148
157
'id ' => 'test '
149
- ]);
158
+ ]
159
+ );
150
160
}
151
161
152
162
public function testIdCannotBeEmptyStringForDelete ()
@@ -156,11 +166,13 @@ public function testIdCannotBeEmptyStringForDelete()
156
166
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
157
167
$ this ->expectExceptionMessage ('id cannot be an empty string ' );
158
168
159
- $ client ->delete ([
169
+ $ client ->delete (
170
+ [
160
171
'index ' => 'test ' ,
161
172
'type ' => 'test ' ,
162
173
'id ' => ''
163
- ]);
174
+ ]
175
+ );
164
176
}
165
177
166
178
public function testIndexCannotBeArrayOfEmptyStringsForDelete ()
@@ -170,11 +182,13 @@ public function testIndexCannotBeArrayOfEmptyStringsForDelete()
170
182
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
171
183
$ this ->expectExceptionMessage ('index cannot be an array of empty strings ' );
172
184
173
- $ client ->delete ([
185
+ $ client ->delete (
186
+ [
174
187
'index ' => ['' , '' , '' ],
175
188
'type ' => 'test ' ,
176
189
'id ' => 'test '
177
- ]);
190
+ ]
191
+ );
178
192
}
179
193
180
194
public function testTypeCannotBeArrayOfEmptyStringsForDelete ()
@@ -184,11 +198,13 @@ public function testTypeCannotBeArrayOfEmptyStringsForDelete()
184
198
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
185
199
$ this ->expectExceptionMessage ('type cannot be an array of empty strings ' );
186
200
187
- $ client ->delete ([
201
+ $ client ->delete (
202
+ [
188
203
'index ' => 'test ' ,
189
204
'type ' => ['' , '' , '' ],
190
205
'id ' => 'test '
191
- ]);
206
+ ]
207
+ );
192
208
}
193
209
194
210
public function testIndexCannotBeArrayOfNullsForDelete ()
@@ -198,11 +214,13 @@ public function testIndexCannotBeArrayOfNullsForDelete()
198
214
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
199
215
$ this ->expectExceptionMessage ('index cannot be an array of empty strings ' );
200
216
201
- $ client ->delete ([
217
+ $ client ->delete (
218
+ [
202
219
'index ' => [null , null , null ],
203
220
'type ' => 'test ' ,
204
221
'id ' => 'test '
205
- ]);
222
+ ]
223
+ );
206
224
}
207
225
208
226
public function testTypeCannotBeArrayOfNullsForDelete ()
@@ -212,11 +230,13 @@ public function testTypeCannotBeArrayOfNullsForDelete()
212
230
$ this ->expectException (Elasticsearch \Common \Exceptions \InvalidArgumentException::class);
213
231
$ this ->expectExceptionMessage ('type cannot be an array of empty strings ' );
214
232
215
- $ client ->delete ([
233
+ $ client ->delete (
234
+ [
216
235
'index ' => 'test ' ,
217
236
'type ' => [null , null , null ],
218
237
'id ' => 'test '
219
- ]);
238
+ ]
239
+ );
220
240
}
221
241
222
242
public function testMaxRetriesException ()
@@ -272,39 +292,49 @@ public function testMaxRetriesException()
272
292
273
293
public function testInlineHosts ()
274
294
{
275
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
295
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
296
+ [
276
297
'localhost:9200 '
277
- ])->build ();
298
+ ]
299
+ )->build ();
278
300
$ host = $ client ->transport ->getConnection ();
279
301
$ this ->assertSame ("localhost:9200 " , $ host ->getHost ());
280
302
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
281
303
282
304
283
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
305
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
306
+ [
284
307
'http://localhost:9200 '
285
- ])->build ();
308
+ ]
309
+ )->build ();
286
310
$ host = $ client ->transport ->getConnection ();
287
311
$ this ->assertSame ("localhost:9200 " , $ host ->getHost ());
288
312
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
289
313
290
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
314
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
315
+ [
291
316
'http://foo.com:9200 '
292
- ])->build ();
317
+ ]
318
+ )->build ();
293
319
$ host = $ client ->transport ->getConnection ();
294
320
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
295
321
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
296
322
297
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
323
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
324
+ [
298
325
'https://foo.com:9200 '
299
- ])->build ();
326
+ ]
327
+ )->build ();
300
328
$ host = $ client ->transport ->getConnection ();
301
329
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
302
330
$ this ->assertSame ("https " , $ host ->getTransportSchema ());
303
331
304
332
305
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
333
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
334
+ [
306
335
'https://user:[email protected] :9200 '
307
- ])->build ();
336
+ ]
337
+ )->build ();
308
338
$ host = $ client ->transport ->getConnection ();
309
339
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
310
340
$ this ->assertSame ("https " , $ host ->getTransportSchema ());
@@ -313,106 +343,124 @@ public function testInlineHosts()
313
343
314
344
public function testExtendedHosts ()
315
345
{
316
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
346
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
347
+ [
317
348
[
318
349
'host ' => 'localhost ' ,
319
350
'port ' => 9200 ,
320
351
'scheme ' => 'http '
321
352
]
322
- ])->build ();
353
+ ]
354
+ )->build ();
323
355
$ host = $ client ->transport ->getConnection ();
324
356
$ this ->assertSame ("localhost:9200 " , $ host ->getHost ());
325
357
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
326
358
327
359
328
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
360
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
361
+ [
329
362
[
330
363
'host ' => 'foo.com ' ,
331
364
'port ' => 9200 ,
332
365
'scheme ' => 'http '
333
366
]
334
- ])->build ();
367
+ ]
368
+ )->build ();
335
369
$ host = $ client ->transport ->getConnection ();
336
370
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
337
371
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
338
372
339
373
340
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
374
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
375
+ [
341
376
[
342
377
'host ' => 'foo.com ' ,
343
378
'port ' => 9200 ,
344
379
'scheme ' => 'https '
345
380
]
346
- ])->build ();
381
+ ]
382
+ )->build ();
347
383
$ host = $ client ->transport ->getConnection ();
348
384
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
349
385
$ this ->assertSame ("https " , $ host ->getTransportSchema ());
350
386
351
387
352
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
388
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
389
+ [
353
390
[
354
391
'host ' => 'foo.com ' ,
355
392
'scheme ' => 'http '
356
393
]
357
- ])->build ();
394
+ ]
395
+ )->build ();
358
396
$ host = $ client ->transport ->getConnection ();
359
397
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
360
398
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
361
399
362
400
363
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
401
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
402
+ [
364
403
[
365
404
'host ' => 'foo.com '
366
405
]
367
- ])->build ();
406
+ ]
407
+ )->build ();
368
408
$ host = $ client ->transport ->getConnection ();
369
409
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
370
410
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
371
411
372
412
373
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
413
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
414
+ [
374
415
[
375
416
'host ' => 'foo.com ' ,
376
417
'port ' => 9500 ,
377
418
'scheme ' => 'https '
378
419
]
379
- ])->build ();
420
+ ]
421
+ )->build ();
380
422
$ host = $ client ->transport ->getConnection ();
381
423
$ this ->assertSame ("foo.com:9500 " , $ host ->getHost ());
382
424
$ this ->assertSame ("https " , $ host ->getTransportSchema ());
383
425
384
426
385
427
try {
386
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
428
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
429
+ [
387
430
[
388
431
'port ' => 9200 ,
389
432
'scheme ' => 'http '
390
433
]
391
- ])->build ();
434
+ ]
435
+ )->build ();
392
436
$ this ->fail ("Expected RuntimeException from missing host, none thrown " );
393
437
} catch (Elasticsearch \Common \Exceptions \RuntimeException $ e ) {
394
438
// good
395
439
}
396
440
397
441
// Underscore host, questionably legal, but inline method would break
398
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
442
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
443
+ [
399
444
[
400
445
'host ' => 'the_foo.com '
401
446
]
402
- ])->build ();
447
+ ]
448
+ )->build ();
403
449
$ host = $ client ->transport ->getConnection ();
404
450
$ this ->assertSame ("the_foo.com:9200 " , $ host ->getHost ());
405
451
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
406
452
407
453
408
454
// Special characters in user/pass, would break inline
409
- $ client = Elasticsearch \ClientBuilder::create ()->setHosts ([
455
+ $ client = Elasticsearch \ClientBuilder::create ()->setHosts (
456
+ [
410
457
[
411
458
'host ' => 'foo.com ' ,
412
459
'user ' => 'user ' ,
413
460
'pass ' => 'abc#$@?%!abc '
414
461
]
415
- ])->build ();
462
+ ]
463
+ )->build ();
416
464
$ host = $ client ->transport ->getConnection ();
417
465
$ this ->assertSame ("foo.com:9200 " , $ host ->getHost ());
418
466
$ this ->assertSame ("http " , $ host ->getTransportSchema ());
0 commit comments