如何在Laravel 5.6中处理验证异常测试用例?

我在Laravel 5.6中编写了用于更新配置文件的测试用例。我正在检查无效的电子邮件验证测试用例,但是当我尝试执行测试用例时,得到的响应却不足。

{"status":false,"errorCode":"VALIDATION_EXCEPTION","messages":{"email":["The email field must be a valid formatted email address"]}}

请在下面找到我的代码

   public function user_profile_update_with_invalid_email()
   {
       $request = [
           'email'  => 'test',];
       $response = $this->postJson(route('user.profile-update',['user id goes here']),$request);
       $response->assertStatus(200)
           ->assertJson(['status' => false]);
   }

我通过编写以下行来执行测试用例

vendor/bin/phpunit --filter user_profile_update_with_invalid_email

预期输出为:

OK (1 test,2 assertions)

当前输出为:

{"status":false,"messages":{"email":["The email field must be a valid formatted email address"]}}

能否让我知道是什么问题?

我该怎么做?

谢谢。

blackless 回答:如何在Laravel 5.6中处理验证异常测试用例?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3109209.html

大家都在问