20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
|
|
@ -1,14 +1,54 @@
|
|||
<?php
|
||||
|
||||
use App\Models\RegistrationCode;
|
||||
use App\Models\User;
|
||||
use Livewire\Volt\Volt;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
test('registration screen can be rendered', function () {
|
||||
$response = $this->get('/register');
|
||||
test('registration landing page can be rendered for valid role', function () {
|
||||
Role::create([
|
||||
'name' => 'Broker',
|
||||
'guard_name' => 'web',
|
||||
'reg_prefix' => 'M',
|
||||
'can_be_invited' => true,
|
||||
'reg_start_number' => 10000001,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response = $this->get('/reg/m');
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('new users can register', function () {
|
||||
test('registration landing page returns 404 for invalid role', function () {
|
||||
$response = $this->get('/reg/invalid');
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('registration requires valid code in session', function () {
|
||||
$response = Volt::test('auth.register')
|
||||
->set('name', 'Test User')
|
||||
->set('email', 'test@example.com')
|
||||
->set('password', 'password')
|
||||
->set('password_confirmation', 'password')
|
||||
->call('register');
|
||||
|
||||
$response->assertHasErrors('registration_code');
|
||||
});
|
||||
|
||||
test('new users can register with valid registration code', function () {
|
||||
$code = RegistrationCode::create([
|
||||
'code' => 'M10000001',
|
||||
'role' => 'broker',
|
||||
'name' => 'Test Makler',
|
||||
'status' => RegistrationCode::STATUS_AVAILABLE,
|
||||
]);
|
||||
|
||||
session([
|
||||
'registration_code_id' => $code->id,
|
||||
'registration_role' => 'broker',
|
||||
]);
|
||||
|
||||
$response = Volt::test('auth.register')
|
||||
->set('name', 'Test User')
|
||||
->set('email', 'test@example.com')
|
||||
|
|
@ -21,4 +61,7 @@ test('new users can register', function () {
|
|||
->assertRedirect(route('dashboard', absolute: false));
|
||||
|
||||
$this->assertAuthenticated();
|
||||
|
||||
expect(User::where('email', 'test@example.com')->exists())->toBeTrue();
|
||||
expect($code->fresh()->status)->toBe(RegistrationCode::STATUS_USED);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue