File manager - Edit - /var/www/html/pcadigital/api/tests/Feature/AuthTest.php
Back
<?php namespace Tests\Feature; // use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use Illuminate\Http\JsonResponse; use Illuminate\Foundation\Testing\DatabaseTransactions; class AuthTest extends TestCase { /** * A basic test example. * * @return void */ public function test_login() { $response = $this->withHeaders([ 'Accept' => 'application/json', ])->post(route('auth.login'), [ 'cpf' => '67108857049', 'password' => 'angra123' ]); $response->assertStatus(JsonResponse::HTTP_OK); $response->assertSee('access_token'); } public function test_login_without_cpf_or_password() { $response = $this->withHeaders([ 'Accept' => 'application/json', ])->post(route('auth.login'), [ 'password' => 'angra123' ]); $response->assertStatus(JsonResponse::HTTP_UNPROCESSABLE_ENTITY); $response->assertSee('errors'); $response = $this->withHeaders([ 'Accept' => 'application/json', ])->post(route('auth.login'), [ 'cpf' => '67108857049', ]); $response->assertStatus(JsonResponse::HTTP_UNPROCESSABLE_ENTITY); $response->assertSee('errors'); } public function test_logout() { // logging in $response = $this->withHeaders([ 'Accept' => 'application/json', ])->post(route('auth.login'), [ 'cpf' => '67108857049', 'password' => 'angra123' ]); $response->assertStatus(JsonResponse::HTTP_OK); $response->assertSee('access_token'); // logging out $response = $this->withHeaders([ 'Accept' => 'application/json', 'Authorization' => 'Bearer ' . $response['access_token'] ])->post(route('auth.logout')); $response->assertStatus(JsonResponse::HTTP_NO_CONTENT); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings