toBe($expectedService, "Service name mismatch for $varName"); expect($parsed['port'])->toBe($expectedPort, "Port mismatch for $varName"); expect($parsed['has_port'])->toBe($isPortSpecific, "Port detection mismatch for $varName"); } }); it('correctly identifies service name with various patterns', function () { // Test service name extraction with different patterns $testCases = [ // After parsing, service names should preserve underscores ['SERVICE_URL_MY_API_8080', 'my_api'], ['SERVICE_URL_REDIS_CACHE_6379', 'redis_cache'], ['SERVICE_URL_NEW_API_3000', 'new_api'], ['SERVICE_FQDN_DB_SERVER_5432', 'db_server'], // Single-word services ['SERVICE_URL_UMAMI_3000', 'umami'], ['SERVICE_URL_MYAPP_8080', 'myapp'], // Without port ['SERVICE_URL_MY_APP', 'my_app'], ['SERVICE_URL_REDIS_PRIMARY', 'redis_primary'], ]; foreach ($testCases as [$varName, $expectedServiceName]) { // Use the actual helper function from bootstrap/helpers/services.php $parsed = parseServiceEnvironmentVariable($varName); expect($parsed['service_name'])->toBe($expectedServiceName, "Service name extraction for $varName"); } });