<?php

it('keeps the legacy operation_type column compatible with v2 operation queueing', function (): void {
    $bootstrapContent = file_get_contents(app_path('classes/edge_gateway_schema_bootstrap.php'));
    $operationServiceContent = file_get_contents(app_path('classes/edge_gateway_operation_service.php'));
    $operationObjectContent = file_get_contents(app_path('objects/edge_gateway_operations_o.php'));

    expect($bootstrapContent)->not->toBeFalse();
    expect($operationServiceContent)->not->toBeFalse();
    expect($operationObjectContent)->not->toBeFalse();

    expect($bootstrapContent)->toContain("ensureColumn('edge_gateway_operations', 'operation_type', \"VARCHAR(32) NOT NULL DEFAULT 'DISCOVERY' AFTER type\")");
    expect($bootstrapContent)->toContain('private static function syncOperationTypeColumns(): void');
    expect($bootstrapContent)->toContain('SET type = operation_type');
    expect($operationServiceContent)->toContain("'operation_type' => \$type");
    expect($operationObjectContent)->toContain("new object_property(\$this->table, \$this->id, 'operation_type', 'string', false)");
});
