0
値上記の例では、指定されたパラメータで要求を作成Behatシナリオ概要フロートは、
Given I am using the API Service
When I send the <request> as <method> to <endpoint> endpoint with <key> having value <value>
Then The response status code is 200
Examples:
| request | method | endpoint | key | value |
| "All Keys" | "POST" | "endpointName" | "numericField" | 15 |
| "All Keys" | "POST" | "endpointName" | "numericField" | 15.12345 |
APIテストのため次のシナリオを検討してください。
私の問題は、integer(15)の値が関数に渡されている間、float(15.12345)が文字列( "15.12345")に変換されるということです。関数が呼び出されると、これはまっすぐに起こります。後で他のステップで変更されることはありません。
フロート値が文字列にならないようにする方法はありますか?要求されたよう
、送信要求ステップの方法は次のとおりです。問題を修正する
$data = $this->fulfilmentOptions->getDataValue($request);
$uri = $this->getMinkParameter('base_url') . $this->setEndpoint($endpoint);
array_walk_recursive($data, function(&$item, $originalKey) use ($key, $value) {
if ($originalKey === $key) {
$item = $value;
}
});
try {
$this->response = $this->client->request($method, $uri, [
'headers' => $this->fulfilmentOptions->getDataValue('CreateOrder API Headers'),
'body' => json_encode($data)
]);
} catch (\GuzzleHttp\Exception\RequestException $e) {
$this->response = $e->getResponse();
}
$this->responseContent = $this->response->getBody()->getContents();
送信要求ステップの実装を追加できますか? – lauda
オリジナルボディに追加しました。ありがとう – Valentin
うーん、私はちょっと、このメソッドを乱雑に伝えることはできません、$キーが値のときに 'floatval'の呼び出しを試みてください。 – lauda