20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
95
tests/Feature/CreateNewUserOriginTest.php
Normal file
95
tests/Feature/CreateNewUserOriginTest.php
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Actions\Fortify\CreateNewUser;
|
||||
use App\Enums\UserOrigin;
|
||||
use App\Models\Hub;
|
||||
|
||||
test('new user gets style2own origin when theme is style2own', function () {
|
||||
config(['app.theme' => 'style2own']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
]);
|
||||
|
||||
expect($user->origin)->toBe(UserOrigin::Style2Own);
|
||||
expect($user->origin->value)->toBe('style2own');
|
||||
});
|
||||
|
||||
test('new user gets stileigentum origin when theme is stileigentum', function () {
|
||||
config(['app.theme' => 'stileigentum']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'Test User 2',
|
||||
'email' => 'test2@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
]);
|
||||
|
||||
expect($user->origin)->toBe(UserOrigin::StilEigentum);
|
||||
expect($user->origin->value)->toBe('stileigentum');
|
||||
});
|
||||
|
||||
test('new user has null origin when theme is unknown', function () {
|
||||
config(['app.theme' => 'portal']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'Test User 3',
|
||||
'email' => 'test3@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
]);
|
||||
|
||||
expect($user->origin)->toBeNull();
|
||||
});
|
||||
|
||||
test('new user has null origin when theme is empty', function () {
|
||||
config(['app.theme' => '']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'Test User 4',
|
||||
'email' => 'test4@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
]);
|
||||
|
||||
expect($user->origin)->toBeNull();
|
||||
});
|
||||
|
||||
test('new user stores hub_id when provided', function () {
|
||||
$hub = Hub::factory()->create();
|
||||
config(['app.theme' => '']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'Hub User',
|
||||
'email' => 'hubuser@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
'hub_id' => $hub->id,
|
||||
]);
|
||||
|
||||
expect($user->hub_id)->toBe($hub->id);
|
||||
});
|
||||
|
||||
test('new user has null hub_id when not provided', function () {
|
||||
config(['app.theme' => '']);
|
||||
|
||||
$action = new CreateNewUser;
|
||||
$user = $action->create([
|
||||
'name' => 'No Hub User',
|
||||
'email' => 'nohub@example.com',
|
||||
'password' => 'Password123!',
|
||||
'password_confirmation' => 'Password123!',
|
||||
]);
|
||||
|
||||
expect($user->hub_id)->toBeNull();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue