Compare commits
No commits in common. "ae59f826e9d292ad04c5f9f03d9e0bb4cc353a67" and "8772331868f6578ae983a6a1bf4ad2405528c498" have entirely different histories.
ae59f826e9
...
8772331868
@ -4,8 +4,6 @@
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
@ -18,15 +16,6 @@ public function index()
|
||||
// GET /user/{id}
|
||||
public function show(string $id)
|
||||
{
|
||||
// FIXME: is there more shorter
|
||||
// validation solution
|
||||
$v = Validator::make(["id" => $id], [
|
||||
"id" => 'integer'
|
||||
]);
|
||||
|
||||
if ($v->fails())
|
||||
throw new BadRequestException();
|
||||
|
||||
$user = User::query()->findOrFail($id);
|
||||
|
||||
return response($user);
|
||||
|
10
tests/Feature/CommentaryTest.php
Normal file
10
tests/Feature/CommentaryTest.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class CommentaryTest extends TestCase
|
||||
{
|
||||
//
|
||||
}
|
10
tests/Feature/PostTest.php
Normal file
10
tests/Feature/PostTest.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class PostTest extends TestCase
|
||||
{
|
||||
//
|
||||
}
|
10
tests/Feature/TagTest.php
Normal file
10
tests/Feature/TagTest.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class TagTest extends TestCase
|
||||
{
|
||||
//
|
||||
}
|
@ -3,14 +3,12 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
// FIXME: tests should be
|
||||
// grouped and be separated in several files
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_success_get_users(): void
|
||||
{
|
||||
@ -36,6 +34,6 @@ public function test_fail_get_user_not_exists(): void
|
||||
// but in future updates id
|
||||
// will be uuid, it is safer
|
||||
$this->get('/user/sehtrgher')
|
||||
->assertBadRequest();
|
||||
->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,9 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
protected $seed = true;
|
||||
//
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user