php - 对于每个带有 laravel 测试 api 的
问题描述
这是我的测试 WP 方法
public function testGetWP()
{
$this->actingAs($this->user, 'api');
$response = $this->get('/api/w-parm', ['Content-Type' => 'application/x-www-form-urlencoded'
])->assertStatus(200);
$w_parms = WParm::get();
foreach ($w_parms as $w_parm) {
$response->assertJson([
"data" => [
[
"id" => $w_parameter->id,
"name_en" => $w_parameter->name_en,
]
])
}
}
但我得到了这个失败的断言
无法断言数组具有子集 Array &0 (
'data' => Array &1 (
0 => Array &2 (
'id' => 5
'name_en' => 'Www'
)
)
).
--- Expected
+++ Actual
@@ @@
- [id] => 5
- [name_en] => Wind Speed
+ [id] => 4
+ [name_en] => ww
/code/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:290
解决方案
推荐阅读
- typescript - 如何正确提交角度形式?
- python - discord.py - 发送文件而不在我的计算机上创建文件?
- vue.js - 主组件内的多个 Vue 组件
- javascript - 通过 AJAX 调用控制器时返回文件不起作用
- node.js - node.js lambda 中的标头未设置
- python-3.x - ipysheet 和数据框。选中复选框时如何修改ipysheet中的值
- wordpress - WordPress 古腾堡 .updateBlock
- c++ - 将包含在 2 个链表中的相同值写入另一个链表
- c# - SSIS 脚本组件读取 Web 数据但不创建 Output0Buffer 对象
- javascript - 多个 mongo 查询然后返回响应