From 4cf01d735825c91312278f5aca0fe88c235597ca Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 19 Apr 2019 18:09:05 +1000 Subject: [PATCH] tests for login --- tests/Feature/LoginTest.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index acc3ecb3d8..cea52a547f 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -125,4 +125,36 @@ class LoginTest extends TestCase $this->assertGuest(); } + public function testApiLogin() + { + $account = factory(Account::class)->create(); + $user = factory(User::class)->create([ + 'account_id' => $account->id, + 'email' => 'test@example.com', + 'password' => '123456' + ]); + + $company = factory(\App\Models\Company::class)->make([ + 'account_id' => $account->id, + ]); + + $user->companies()->attach($company->id, [ + 'account_id' => $account->id, + 'is_owner' => 1, + 'is_admin' => 1, + ]); + + $data = [ + 'email' => 'test@example.com', + 'password' => '123456' + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + ])->post('/api/v1/login', $data); + + + $response->assertStatus(200); + } + }