$builder =
new ClientBuilder();
$builder->
setHandler(fn () =>
new FutureArray(resolve([ 'status' => 200,
'body' =>
fopen('php://memory', 'rb'
),
'transfer_stats' =>
[ 'total_time' => 0,
],
'effective_url' => 'http://localhost:9200/test/_search',
])));
$profiler =
new ClientProfiler($builder->
build());
$request =
['index' =>
$index, 'body' =>
['query' =>
['match_all' =>
[]]]];
$profiler->
search($request);
static::
assertCount(1,
$profiler->
getCalledRequests());
$requests =
$profiler->
getCalledRequests();
static::
assertSame($expectedUrl,
$requests[0
]['url'
]);
static::
assertEquals($request,
$requests[0
]['request'
]);
$profiler->
resetRequests();
static::
assertCount(0,
$profiler->
getCalledRequests());
}