laravel - PHP 单元测试 Laravel
问题描述
我无法在 PHPUnit 中解决这个问题。在 Postman 中它运行良好,但在 PHPUnit 中出现错误。
class MyPageTakumoiTest extends TestCase
{
protected $api = "/api/my_page_takumoi/2";
public function testUpdate()
{
$response = $this->json('PUT', $this->api, [
'family_name' => 'new kk',
]);
$response->assertStatus(200);
}
}
Expected status code 200 but received 500.
Failed asserting that 200 is identical to 500.
解决方案
您可以在测试开始时使用它来获得更好的异常:
$this->withoutExceptionHandling();
推荐阅读
- javascript - Javascript 类切换
- python - 从多列条件中将na填充到pandas的列中
- r - 在 R 中设置表的子集
- r - 如何将 mapply 转换为 pmap 或类似的,以便可以在 R 中对数据进行分组
- deployment - Plotly.js IIS 部署 - WebGL 设置失败
- angular - 使用变量作为属性名称(例如在角度路由器中)
- sql - 为什么正常 SELECT 和 SELECT INTO 的“受影响的行数”不同?
- sql - SQL 中的 YEAR() 如何正确使用 year()
- python - numpy.astype(np.uint8) 如何转换浮点数组?-1.2997805 变为 255
- c - 无法使用 fgets 和 scanf 函数输入单词