<?php

it('unregisters legacy booking completion forms', function (): void {
    $formFile = app_path('classes/form.php');
    $code = (string)file_get_contents($formFile);

    expect(is_file(app_path('modules/forms/objects/complete_booking_f.php')))->toBeFalse();
    expect(is_file(app_path('modules/forms/objects/generate_booking_wash_certificate_f.php')))->toBeFalse();
    expect($code)->not->toContain('complete_booking_f');
    expect($code)->not->toContain('generate_booking_wash_certificate_f');
    expect($code)->not->toContain('COMPLETE_BOOKING_WITHOUT_WASH_CERTIFICATE');
    expect($code)->not->toContain('GENERATE_BOOKING_WASH_CERTIFICATE');
});

it('keeps legacy wash certificate downloads but removes disabled generation and completion code', function (): void {
    $code = (string)file_get_contents(app_path('modules/washcertificates/index.php'));

    $downloadPosition = strpos($code, "isset(\$_GET['justDownload'])");
    $disabledPosition = strpos($code, 'http_response_code(410)');
    $completionPosition = strpos($code, "\$booking->status->set('completed')");

    expect($downloadPosition)->not->toBeFalse();
    expect($disabledPosition)->not->toBeFalse();
    expect($completionPosition)->toBeFalse();
    expect($downloadPosition)->toBeLessThan($disabledPosition);
    expect($code)->not->toContain('new WashCertificateGenerator');
    expect($code)->toContain('Booking completion must be completed through POS desktop or mobile steps.');
});
