<?php

namespace classes {
    // Minimal stubs to satisfy class loading without full app bootstrap
    class db {}
    class object_property {
        public function __construct(...$args) {}
        public function value() { return null; }
        public function set($v) {}
    }
}

namespace traits {
    trait db_object_t {}
}

namespace {
    // Lightweight bootstrap for CLI execution without full index.php
    if (!defined('WD')) {
        define('WD', __DIR__ . '/../../');
    }

    require_once WD . 'objects/department_selfserve_tasks_o.php';

    use objects\department_selfserve_tasks_o;

    function ok($message): void { echo "\n\033[32m✔ $message\033[0m\n"; }
    function fail($message): void { echo "\n\033[31m✖ $message\033[0m\n"; }

    echo "\nDynamicImagesVehicleTypeNormalizationTest starting...\n";

    // 1) Integer input
    try {
        $v = department_selfserve_tasks_o::normalizeVehicleTypeInput(3);
        if ($v === 3) { ok('Integer input accepted'); } else { fail('Integer input mismatch: ' . var_export($v, true)); }
    } catch (\Exception $e) { fail('Integer input threw: ' . $e->getMessage()); }

    // 2) Numeric string input
    try {
        $v = department_selfserve_tasks_o::normalizeVehicleTypeInput('4');
        if ($v === 4) { ok('Numeric string input accepted'); } else { fail('Numeric string mismatch: ' . var_export($v, true)); }
    } catch (\Exception $e) { fail('Numeric string input threw: ' . $e->getMessage()); }

    // 3) Trimmed numeric string with spaces
    try {
        $v = department_selfserve_tasks_o::normalizeVehicleTypeInput(' 5 ');
        if ($v === 5) { ok('Trimmed numeric string input accepted'); } else { fail('Trimmed numeric string mismatch: ' . var_export($v, true)); }
    } catch (\Exception $e) { fail('Trimmed numeric string input threw: ' . $e->getMessage()); }

    // 4) Null input -> null
    try {
        $v = department_selfserve_tasks_o::normalizeVehicleTypeInput(null);
        if ($v === null) { ok('Null input returns null'); } else { fail('Null input mismatch: ' . var_export($v, true)); }
    } catch (\Exception $e) { fail('Null input threw: ' . $e->getMessage()); }

    // 5) Empty string -> null
    try {
        $v = department_selfserve_tasks_o::normalizeVehicleTypeInput('');
        if ($v === null) { ok('Empty string treated as null'); } else { fail('Empty string mismatch: ' . var_export($v, true)); }
    } catch (\Exception $e) { fail('Empty string threw: ' . $e->getMessage()); }

    // 6) Negative value should throw
    $thrown = false;
    try {
        department_selfserve_tasks_o::normalizeVehicleTypeInput(-1);
    } catch (\Exception $e) {
        $thrown = true; ok('Negative value correctly threw: ' . $e->getMessage());
    }
    if (!$thrown) { fail('Expected exception for negative value, but none was thrown'); }

    // 7) Non-numeric string should throw
    $thrown = false;
    try {
        department_selfserve_tasks_o::normalizeVehicleTypeInput('abc');
    } catch (\Exception $e) {
        $thrown = true; ok('Non-numeric string correctly threw: ' . $e->getMessage());
    }
    if (!$thrown) { fail('Expected exception for non-numeric string, but none was thrown'); }

    echo "\nDynamicImagesVehicleTypeNormalizationTest completed.\n";
}
