laravel-api-simple-blog/tests/Feature/UserTest.php

40 lines
895 B
PHP

<?php
namespace Tests\Feature;
use App\Models\User;
use Tests\TestCase;
class UserTest extends TestCase
{
// FIXME: tests should be
// grouped and be separated in several files
public function test_success_get_users(): void
{
$this->get('/user')
->assertStatus(200);
}
public function test_success_get_one_user(): void
{
$user = User::factory()->create();
$this->get('/user/' . $user->id)
->assertStatus(200);
}
public function test_fail_get_user_not_exists(): void
{
$this->get('/user/99999999')
->assertNotFound();
// FIXME: Not Fount or Bad request? or any else error?
// Maybe parse exception: id is numeric
// but in future updates id
// will be uuid, it is safer
$this->get('/user/sehtrgher')
->assertNotFound();
}
}