<?php

it('normalizes request identifiers before user lookups', function (): void {
    $usersFile = app_path('objects/users_o.php');
    $content = file_get_contents($usersFile);

    expect($content)->not->toBeFalse();
    expect($content)->toContain('$user_id = $this->parsePositiveIntFromRequest($data[\'user_id\'] ?? null);');
    expect($content)->toContain('$customer_number = $this->parsePositiveIntFromRequest($data[\'customer_number\'] ?? null);');
    expect($content)->toContain('return $this->getUserByCustomerNumber($customer_number);');
    expect($content)->not->toContain('return $this->getUserByCustomerNumber($data[\'customer_number\']);');
});

it('rejects non-positive and non-digit request values', function (): void {
    $usersFile = app_path('objects/users_o.php');
    $content = file_get_contents($usersFile);

    expect($content)->not->toBeFalse();
    expect($content)->toContain('private function parsePositiveIntFromRequest(mixed $value): ?int');
    expect($content)->toContain('$value = trim($value);');
    expect($content)->toContain('!ctype_digit($value)');
    expect($content)->toContain('return $parsed > 0 ? $parsed : null;');
});
