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

40 lines
892 B
PHP
Raw Normal View History

2024-10-15 19:58:33 +03:00
<?php
namespace Tests\Feature;
use App\Models\User;
2024-10-15 19:58:33 +03:00
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::query()->first();
$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();
}
2024-10-15 19:58:33 +03:00
}