-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
use App\Models\User; | ||
use Illuminate\Support\Facades\Hash; | ||
use Tymon\JWTAuth\Facades\JWTAuth; | ||
|
||
/** | ||
* @internal | ||
|
@@ -26,4 +27,40 @@ public function testLogin() | |
$this->post('auth/login', ['email' => '[email protected]', 'password' => $password]) | ||
->seeStatusCode(401); | ||
} | ||
|
||
public function testLogout() | ||
{ | ||
$this->refreshApplication(); | ||
|
||
$user = User::factory()->create(); | ||
// NOTE: in order to make logout() function working we have to pass the JWT token -> can't use standard actingAs function | ||
$token = JWTAuth::fromUser($user); | ||
|
||
$this->post('auth/logout', [], ['Authorization' => 'Bearer ' . $token]) | ||
->seeStatusCode(200) | ||
->seeJson(['message' => 'Successfully logged out']); | ||
} | ||
|
||
public function testRefresh() | ||
{ | ||
$this->refreshApplication(); | ||
|
||
$user = User::factory()->create(); | ||
// NOTE: in order to make logout() function working we have to pass the JWT token -> can't use standard actingAs function | ||
$token = JWTAuth::fromUser($user); | ||
|
||
$this->post('auth/refresh', [], ['Authorization' => 'Bearer ' . $token]) | ||
->seeStatusCode(200) | ||
->seeJson(['token_type' => 'bearer']); | ||
} | ||
|
||
public function testMe() | ||
{ | ||
$user = User::factory()->create(); | ||
$this->actingAs($user); | ||
|
||
$this->get('auth/me') | ||
->seeStatusCode(200) | ||
->seeJson(['id' => $user->id, 'email' => $user->email]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use App\Models\Post; | ||
use App\Models\User; | ||
use Illuminate\Support\Str; | ||
|
||
class MultipartFormDataTest extends TestCase | ||
{ | ||
public function testMultipartPutRequest() | ||
{ | ||
$user = User::factory()->create(); | ||
$post = Post::factory()->create([ | ||
'user_id' => $user->id, | ||
]); | ||
$newText = Str::random(300); | ||
|
||
$this->actingAs($user); | ||
$this->put( | ||
'posts/' . $post->id, | ||
['text' => $newText], | ||
['Content-Type' => 'multipart/form-data'] | ||
) | ||
->seeStatusCode(200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters