trypost/tests/Feature/Auth/RegistrationTest.php

35 lines
992 B
PHP

<?php
use App\Models\User;
test('registration screen can be rendered', function () {
$response = $this->get(route('register'));
$response->assertOk();
});
test('new users can register', function () {
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
]);
$response->assertSessionHasNoErrors();
$this->assertAuthenticated();
$response->assertRedirect(route('onboarding.step1', absolute: false));
});
test('new users get a default workspace on registration', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user)->not->toBeNull();
expect($user->workspaces)->toHaveCount(1);
expect($user->workspaces->first()->name)->toBe('My Workspace');
});