'testing', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441', 'DB_DATABASE' => $target['database'], 'DB_USERNAME' => 'postgres', 'DB_PASSWORD' => '', 'DB_URL' => ''] as $key => $value) { putenv($key.'='.$value); $_ENV[$key] = $_SERVER[$key] = $value; } require $root.'/vendor/autoload.php'; $app = require $root.'/bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); $identity = DB::selectOne('SELECT current_database() AS database,inet_server_port() AS port'); if ($identity->database !== $target['database'] || (int) $identity->port !== 55441) { throw new RuntimeException('Refusing unexpected connection.'); } DB::beginTransaction(); DB::statement('SET TRANSACTION READ ONLY'); $rows = DB::table('geo_geometries')->where('source_system', 'ine-cod-ab')->whereNull('deleted_at')->orderBy('id')->get(['id', 'geo_location_id']); $results = []; $service = app(TerritoryGeometry::class); foreach ($rows as $row) { $private = $service->context($row->geo_location_id, true); $public = $service->context($row->geo_location_id, false); if (! $private['selected_geometry_available'] || $public['context_geometry_count'] !== 0) { throw new RuntimeException('Geometry recovery or privacy mismatch.'); } $results[] = ['geometry_id' => $row->id, 'territory_id' => $row->geo_location_id, 'selected_available_manager' => true, 'context_geometry_count_manager' => $private['context_geometry_count'], 'public_context_count' => $public['context_geometry_count'], 'editions' => array_values(array_unique(array_column($private['areas'], 'source_date')))]; } $examples = []; foreach (['province', 'district', 'admin_post'] as $type) { $example = DB::table('geo_geometries as g')->join('geo_locations as l', 'l.id', '=', 'g.geo_location_id') ->where('g.source_system', 'ine-cod-ab')->whereNull('g.deleted_at')->where('l.location_type', $type) ->orderBy('l.name')->first(['l.id', 'l.name', 'l.location_type']); if ($example) { $examples[] = $example; } } DB::rollBack(); $result = ['captured_at' => gmdate('c'), 'target' => $target, 'read_only' => true, 'real_geometries_checked' => count($rows), 'results' => $results, 'active_writes' => 0, 'qa_writes' => 0, 'public_geometries_promoted' => 0, 'visual_verified' => false, 'selector_examples' => $examples, 'scope' => 'Service recovery of every retained real QA administrative boundary; synthetic HTTP profile authorization is demonstrated separately by PortalAuditConsumerLotTest']; file_put_contents($dir.($pathQa ? '/geometry-consumers-path-qa.json' : '/geometry-consumers-lote3.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo json_encode(['checked' => count($rows), 'private_recovery' => 'passed', 'public_leak' => 0, 'active_writes' => 0, 'visual_verified' => false]).PHP_EOL;