39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
use objects\users_o;
|
|
|
|
function invoke_users_private_static(string $method, array $args = []): mixed
|
|
{
|
|
$reflection = new ReflectionClass(users_o::class);
|
|
$target = $reflection->getMethod($method);
|
|
$target->setAccessible(true);
|
|
return $target->invokeArgs(null, $args);
|
|
}
|
|
|
|
it('builds customer name cache payloads from economic data or display-name fallbacks', function (): void {
|
|
expect(invoke_users_private_static('buildCustomerNameCachePayload', [
|
|
(object)['name' => 'Truckwash ApS'],
|
|
'Fallback Name',
|
|
]))->toBe(['name' => 'Truckwash ApS']);
|
|
|
|
expect(invoke_users_private_static('buildCustomerNameCachePayload', [
|
|
null,
|
|
'Fallback Name',
|
|
]))->toBe(['name' => 'Fallback Name']);
|
|
|
|
expect(invoke_users_private_static('buildCustomerNameCachePayload', [
|
|
(object)['name' => ' '],
|
|
null,
|
|
]))->toBeNull();
|
|
});
|
|
|
|
it('guards bulk customer-name cache writes behind a resolved payload check', function (): void {
|
|
$usersFile = app_path('objects/users_o.php');
|
|
$content = file_get_contents($usersFile);
|
|
|
|
expect($content)->not->toBeFalse();
|
|
expect($content)->toContain('$cache_payload = self::buildCustomerNameCachePayload($cached_name, $fallback_name);');
|
|
expect($content)->toContain('if ($cache_payload !== null) {');
|
|
expect($content)->toContain("\$this->cache('economic_customer_name', \$cache_payload, \$customer_number);");
|
|
});
|