アプリ/コントローラー/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","行":20}}