gpt4 book ai didi

php - 即使存在片段,assertJson 也会失败

转载 作者:行者123 更新时间:2023-11-28 20:28:21 24 4
gpt4 key购买 nike

即使响应中存在片段,assertJson 也会失败:

// test
...
$response->assertJson([
'type' => 'multiple_choice'
]);
...

响应转储

.....array:3 [
0 => {#1503
+"id": 1
+"title_en": "Multiple Choice"
+"title_fr": "Multiple Choice"
+"type": "multiple_choice"
+"created_at": null
+"updated_at": null
}
1 => {#1143
+"id": 2
+"title_en": "Multiple Select"
+"title_fr": "Multiple Select"
+"type": "multiple_select"
+"created_at": null
+"updated_at": null
}
2 => {#981
+"id": 3
+"title_en": "Text"
+"title_fr": "Text"
+"type": "text"
+"created_at": null
+"updated_at": null
}
]

最佳答案

使用

$response->assertJsonFragment([
'type' => 'multiple_choice'
]);

关于php - 即使存在片段,assertJson 也会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42442401/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com