<?php

it('wires stripe payment intent persistence to prune duplicates and clear reader state safely', function (): void {
    $objectFile = app_path('objects/stripe_payment_intents_o.php');
    $content = file_get_contents($objectFile);

    expect($content)->not->toBeFalse();
    expect($content)->toContain("new object_property(\$this->table, \$this->id, 'reader_id', 'string', false);");
    expect($content)->toContain('clearOrderPaymentIntents($order_id);');
    expect($content)->toContain('public function getOrderPaymentIntentRows(int $order_id): array');
    expect($content)->toContain('usort($rows');
    expect($content)->toContain('public function clearOrderPaymentIntents(int $order_id, ?int $keepId = null): void');
    expect($content)->toContain("self::delete_object(\$this->getTable(), \$rowId);");
    expect($content)->toContain('public function updateStoredPaymentIntent(mixed $paymentIntent): void');
    expect($content)->toContain('public function setReaderId(?string $readerId): void');
    expect($content)->toContain('sendCancelPaymentIntent($readerId);');
    expect($content)->toContain('payment_intents->cancel($paymentIntentId);');
    expect($content)->toContain('deleteDuplicateOrderPaymentIntents(int $order_id, int $keepId): void');
});
