我正在尝试使用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);
}
}
我从结果中得到了
这里是使用邮递员发布的