mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-16 13:38:27 +02:00
Fix first user not being set as admin
This commit is contained in:
parent
b8f290dc97
commit
16bf0e4e6d
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Http\Auth;
|
namespace Tests\Feature\Http\Auth;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
|
|
||||||
@ -94,4 +95,35 @@ public function test_register_with_invalid_data_returns_validation_error()
|
|||||||
])
|
])
|
||||||
->assertStatus(422);
|
->assertStatus(422);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function test_register_first_user_only_as_admin()
|
||||||
|
{
|
||||||
|
$this->assertDatabaseCount('users', 0);
|
||||||
|
|
||||||
|
$response = $this->json('POST', '/user', [
|
||||||
|
'name' => self::USERNAME,
|
||||||
|
'email' => self::EMAIL,
|
||||||
|
'password' => self::PASSWORD,
|
||||||
|
'password_confirmation' => self::PASSWORD,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertDatabaseCount('users', 1);
|
||||||
|
$this->assertDatabaseHas('users', [
|
||||||
|
'name' => self::USERNAME,
|
||||||
|
'email' => self::EMAIL,
|
||||||
|
'is_admin' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->json('POST', '/user', [
|
||||||
|
'name' => 'jane',
|
||||||
|
'email' => 'jane@example.org',
|
||||||
|
'password' => self::PASSWORD,
|
||||||
|
'password_confirmation' => self::PASSWORD,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(1, User::admins()->count());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user