63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Laravel\Fortify\Features;
|
|
|
|
beforeEach(function () {
|
|
$this->skipUnlessFortifyHas(Features::registration());
|
|
});
|
|
|
|
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' => 'John Doe',
|
|
'email' => 'test@example.com',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
'plan' => 'pro',
|
|
]);
|
|
|
|
$response->assertSessionHasNoErrors()
|
|
->assertRedirect(route('pricing', absolute: false));
|
|
|
|
$this->assertAuthenticated();
|
|
});
|
|
|
|
test('new users are given a personal organization to subscribe with', function () {
|
|
$this->post(route('register.store'), [
|
|
'name' => 'John Doe',
|
|
'email' => 'test@example.com',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
'plan' => 'pro',
|
|
]);
|
|
|
|
$user = User::where('email', 'test@example.com')->sole();
|
|
|
|
expect($user->currentOrganization()->first())
|
|
->not->toBeNull()
|
|
->personal_workspace->toBeTrue()
|
|
->lifetime_access->toBeFalse();
|
|
});
|
|
|
|
test('a new user is sent to pricing because they have not subscribed', function () {
|
|
$this->post(route('register.store'), [
|
|
'name' => 'John Doe',
|
|
'email' => 'test@example.com',
|
|
'password' => 'password',
|
|
'password_confirmation' => 'password',
|
|
'plan' => 'pro',
|
|
]);
|
|
|
|
$user = User::where('email', 'test@example.com')->sole();
|
|
|
|
expect($user->hasActiveSubscription())->toBeFalse();
|
|
|
|
$this->actingAs($user)->get(route('dashboard'))->assertRedirect(route('pricing'));
|
|
});
|