Php 在Laravel中测试POST调用时如何传递多维数组?
我正在我的项目中测试一个POST方法,它需要一个多维数组作为参数。如何通过Laravel的Php 在Laravel中测试POST调用时如何传递多维数组?,php,arrays,laravel,testing,Php,Arrays,Laravel,Testing,我正在我的项目中测试一个POST方法,它需要一个多维数组作为参数。如何通过Laravel的post()方法传递此信息?我还在尝试postJson()方法。我正在测试的多阵列是过滤器[“排除”]: 收到错误: ErrorException:传递给illumb\Foundation\Testing\TestCase::postJson()的参数2必须是给定字符串的数组类型 我还尝试将数据作为数组传递,但它没有注意排除筛选器: postJson('api/v1/getHotels', ['northL
post()
方法传递此信息?我还在尝试postJson()
方法。我正在测试的多阵列是过滤器[“排除”]:
收到错误:
ErrorException:传递给illumb\Foundation\Testing\TestCase::postJson()的参数2必须是给定字符串的数组类型
我还尝试将数据作为数组传递,但它没有注意排除筛选器:
postJson('api/v1/getHotels', ['northLatitude' => '45.123456', 'southLatitude' => '45.123456', 'westLongitude' => '9.1234567', 'eastLongitude' => '9.1234567', 'filters["excludes"]' => [1]]
Json_decode($Json,true)将把Json数据转换成数组。
$response=$this->postJson('api/v1/getHotels',Json_decode($Json,true))
将Json转换成数组tanks这是answer@MASIDDIQUI请把你的意见写在回答中,这样问题就可以标记为已回答了
postJson('api/v1/getHotels', ['northLatitude' => '45.123456', 'southLatitude' => '45.123456', 'westLongitude' => '9.1234567', 'eastLongitude' => '9.1234567', 'filters["excludes"]' => [1]]
$response = $this->postJson('api/v1/getHotels', json_decode($json, true))
->dontSeeJson([
'id' => 1,
'name' => 'Hotel-1',
'latitude' => 45.123456,
'longitude' => 9.1234567
]);