<?php
// php tests.php  -> prints one line per case and a total. Expected totals worked out by hand from the rate card.
require __DIR__ . '/quote.php';
$cases = [
  ['Small flat hits the minimum', [20, 'standard'], 13200],
  ['Standard 80 m²', [80, 'standard'], 39600],
  ['Deep clean 120 m² + oven', [120, 'deep', ['oven' => 1]], 102190],
  ['Weekly standard 100 m² (15% off)', [100, 'standard', [], 'weekly'], 42075],
  ['Fortnightly deep 60 m² + windows', [60, 'deep', ['windows' => 1], 'fortnightly'], 46728],
  ['End of lease ignores weekly discount', [90, 'end_of_lease', [], 'weekly'], 94050],
  ['End of lease + 3 carpet rooms + oven', [150, 'end_of_lease', ['carpet_room' => 3, 'oven' => 1], 'once'], 175450],
  ['Upper area limit', [800, 'standard'], 396000],
];
$errors = [
  ['Area too small', [10, 'standard']], ['Area too big', [900, 'deep']], ['Unknown service', [80, 'gutters']],
  ['Unknown extra', [80, 'standard', ['pool' => 1]]], ['Unknown frequency', [80, 'standard', [], 'daily']],
];
$pass = 0; $n = 0;
foreach ($cases as [$name, $args, $want]) { $n++; $got = quote(...$args)['total']; $ok = $got === $want; $pass += $ok;
  printf("%s  %-40s expected $%9s  got $%9s\n", $ok ? 'PASS' : 'FAIL', $name, number_format($want / 100, 2), number_format($got / 100, 2)); }
foreach ($errors as [$name, $args]) { $n++; try { quote(...$args); $ok = false; $msg = 'no error'; } catch (InvalidArgumentException $e) { $ok = true; $msg = $e->getMessage(); }
  $pass += $ok; printf("%s  %-40s refused: %s\n", $ok ? 'PASS' : 'FAIL', $name, $msg); }
printf("\n%d of %d quote tests passed\n", $pass, $n); exit($pass === $n ? 0 : 1);
