29 lines
1.5 KiB
PHP
29 lines
1.5 KiB
PHP
<?php
|
|
|
|
app_require('classes/orders_input_normalizer.php');
|
|
|
|
use classes\orders_input_normalizer;
|
|
|
|
it('normalizes sql and datetime-local created_at values', function (): void {
|
|
expect(orders_input_normalizer::normalizeCreatedAt('2026-04-09 12:34:56'))->toBe('2026-04-09 12:34:56');
|
|
expect(orders_input_normalizer::normalizeCreatedAt('2026-04-09T12:34'))->toBe('2026-04-09 12:34:00');
|
|
expect(orders_input_normalizer::normalizeCreatedAt('2026-04-09T12:34:56'))->toBe('2026-04-09 12:34:56');
|
|
});
|
|
|
|
it('rejects invalid created_at values', function (): void {
|
|
orders_input_normalizer::normalizeCreatedAt('2026/04/09 12:34');
|
|
})->throws(InvalidArgumentException::class, 'created_at must be a valid datetime');
|
|
|
|
it('normalizes include_in_invoice tri-state inputs', function (): void {
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice(null))->toBeNull();
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice('use_department'))->toBeNull();
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice('include'))->toBeTrue();
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice('exclude'))->toBeFalse();
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice(true))->toBeTrue();
|
|
expect(orders_input_normalizer::normalizeIncludeInInvoice(false))->toBeFalse();
|
|
});
|
|
|
|
it('rejects invalid include_in_invoice values', function (): void {
|
|
orders_input_normalizer::normalizeIncludeInInvoice('maybe');
|
|
})->throws(InvalidArgumentException::class, 'include_in_invoice must be use_department, include, or exclude');
|