52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\Models\Tenant;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Laravel\Fortify\Features;
|
|
use Tests\TestCase;
|
|
|
|
class RegistrationTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->skipUnlessFortifyHas(Features::registration());
|
|
}
|
|
|
|
public function test_registration_screen_can_be_rendered()
|
|
{
|
|
$response = $this->get(route('register'));
|
|
|
|
$response->assertOk();
|
|
}
|
|
|
|
public function test_new_users_can_register()
|
|
{
|
|
$response = $this->post(route('register.store'), [
|
|
'tenant_name' => 'ISP Test Network',
|
|
'name' => 'Test User',
|
|
'email' => 'test@example.com',
|
|
'password' => 'Strong!Password123',
|
|
'password_confirmation' => 'Strong!Password123',
|
|
'deployment_type' => 'self_hosted',
|
|
'deployment_domain' => 'ndm.test.example',
|
|
]);
|
|
|
|
$this->assertAuthenticated();
|
|
$response->assertRedirect(route('dashboard', absolute: false));
|
|
$tenant = Tenant::where('slug', 'isp-test-network')->firstOrFail();
|
|
$this->assertDatabaseHas('users', ['tenant_id' => $tenant->id, 'email' => 'test@example.com']);
|
|
$this->assertDatabaseHas('deployment_installations', [
|
|
'tenant_id' => $tenant->id,
|
|
'deployment_type' => 'self_hosted',
|
|
'domain' => 'ndm.test.example',
|
|
'status' => 'pending',
|
|
]);
|
|
}
|
|
}
|