finish register special
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserAuthTest extends TestCase
|
||||
@@ -19,7 +20,7 @@ class UserAuthTest extends TestCase
|
||||
|
||||
$response = $this->get('/api/auth-user');
|
||||
|
||||
$response->assertStatus(200)
|
||||
$response->assertStatus(Response::HTTP_OK)
|
||||
->assertJson([
|
||||
'data' => [
|
||||
'user_id' => $user->id,
|
||||
@@ -32,4 +33,30 @@ class UserAuthTest extends TestCase
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function an_admin_can_add_member()
|
||||
{
|
||||
$this->actingAs($user = factory(User::class)->create(['role' => 2]), 'api');
|
||||
|
||||
$response = $this->post('/api/users', [
|
||||
'name' => 'TestName',
|
||||
'email' => 'test@test.fr',
|
||||
])->assertStatus(Response::HTTP_CREATED);
|
||||
|
||||
$this->assertCount(2, User::all());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function a_non_admin_cant_add_member()
|
||||
{
|
||||
$this->actingAs($user = factory(User::class)->create(), 'api');
|
||||
|
||||
$response = $this->post('/api/users', [
|
||||
'name' => 'TestName',
|
||||
'email' => 'test@test.fr',
|
||||
])->assertStatus(Response::HTTP_FORBIDDEN);
|
||||
|
||||
$this->assertCount(1, User::all());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user