2026-02-23 12:23:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Environment;
|
|
|
|
|
use App\Models\Project;
|
|
|
|
|
use App\Models\Service;
|
|
|
|
|
use App\Models\ServiceApplication;
|
|
|
|
|
use App\Models\ServiceDatabase;
|
|
|
|
|
use App\Models\Team;
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
2026-03-30 11:04:11 +00:00
|
|
|
use Illuminate\Support\Str;
|
2026-02-23 12:23:12 +00:00
|
|
|
|
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
|
|
|
|
|
|
it('returns the correct team through the service relationship chain', function () {
|
|
|
|
|
$team = Team::factory()->create();
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$project = Project::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'Test Project',
|
|
|
|
|
'team_id' => $team->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$environment = Environment::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'name' => 'test-env-'.Str::random(8),
|
2026-02-23 12:23:12 +00:00
|
|
|
'project_id' => $project->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$service = Service::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'supabase',
|
|
|
|
|
'environment_id' => $environment->id,
|
|
|
|
|
'destination_id' => 1,
|
|
|
|
|
'destination_type' => 'App\Models\StandaloneDocker',
|
|
|
|
|
'docker_compose_raw' => 'version: "3"',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$serviceDatabase = ServiceDatabase::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'supabase-db',
|
|
|
|
|
'service_id' => $service->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
expect($serviceDatabase->team())->not->toBeNull()
|
|
|
|
|
->and($serviceDatabase->team()->id)->toBe($team->id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns the correct team for ServiceApplication through the service relationship chain', function () {
|
|
|
|
|
$team = Team::factory()->create();
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$project = Project::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'Test Project',
|
|
|
|
|
'team_id' => $team->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$environment = Environment::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'name' => 'test-env-'.Str::random(8),
|
2026-02-23 12:23:12 +00:00
|
|
|
'project_id' => $project->id,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$service = Service::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'supabase',
|
|
|
|
|
'environment_id' => $environment->id,
|
|
|
|
|
'destination_id' => 1,
|
|
|
|
|
'destination_type' => 'App\Models\StandaloneDocker',
|
|
|
|
|
'docker_compose_raw' => 'version: "3"',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-31 11:45:31 +00:00
|
|
|
$serviceApplication = ServiceApplication::create([
|
2026-03-30 11:04:11 +00:00
|
|
|
'uuid' => (string) Str::uuid(),
|
2026-02-23 12:23:12 +00:00
|
|
|
'name' => 'supabase-studio',
|
|
|
|
|
'service_id' => $service->id,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
expect($serviceApplication->team())->not->toBeNull()
|
|
|
|
|
->and($serviceApplication->team()->id)->toBe($team->id);
|
|
|
|
|
});
|