Laravel单元测试登录始终获得状态500

时间:2020-06-01 13:21:19

标签: laravel unit-testing

我正在尝试使用laravel测试我的api。当我使用正确的电子邮件地址和密码登录时,始终返回“预期状态码200,但收到500。未能断言200与500相同”。 这是我的代码

<?php

namespace Tests\Unit;

// use PHPUnit\Framework\TestCase;
use App\Post;
use Tests\TestCase;

class UserTest extends TestCase
{
    /**
     * A basic unit test example.
     *
     * @return void
     */
    public function testAPI()
    {
        $response = $this->get('/');
        $response->assertStatus(200);
    }
    public function testLogin()
    {
        $response = $this->json('POST','api/login', [
            "email" => "test@gmail.com",
            "password" => "reP@ssw0rd"
        ]);
        $response->assertStatus(200);
    }
}

我从结果中得到了

enter image description here

这里是使用邮递员发布的

enter image description here

0 个答案:

没有答案