应用程序/控制器/SecurityController.php
class SecurityController extends Controller {
public function login()
{
$payload = file_get_contents("php://input");
$payload = json_decode($payload);
$input = array('mail' => $payload->mail,
'password' => $payload->password,
);
if (Auth::attempt($input))
{
}
}
}
应用程序/测试/SecurityTest.php
class SecurityTest extends TestCase {
public function testLogin()
{
$data = array(
'mail' => 'test@test.com',
'password' => 'mypasswprd',
);
$crawler = $this->client->request('POST', '/v2/login', $data);
}
当我运行 phpunit 时出现此错误: .{"error":{"type":"ErrorException","message":"Trying to get property of non-object","file":app/controllers/SecurityController .php","line":20}}