27-05-2026 DHL Modul v2.1 / Optimierung tracking

This commit is contained in:
Kevin Adametz 2026-05-27 18:51:23 +02:00
parent 036595be94
commit 2bdc9ada3c
33 changed files with 2367 additions and 2086 deletions

View file

@ -0,0 +1,47 @@
<?php
use App\Http\Controllers\SettingController;
beforeEach(function () {
SettingController::flushDhlConfigCache();
});
afterEach(function () {
SettingController::flushDhlConfigCache();
});
it('returns the cached DHL configuration without re-reading settings', function () {
$cached = [
'base_url' => 'https://api-eu.dhl.com',
'api_key' => 'cached-api-key',
'username' => 'cached-user',
'password' => 'cached-password',
'account_numbers' => ['V01PAK' => '63144073550101'],
];
$reflection = new ReflectionClass(SettingController::class);
$property = $reflection->getProperty('cachedDhlConfig');
$property->setAccessible(true);
$property->setValue(null, $cached);
$controller = new SettingController;
expect($controller->getDhlConfig())->toBe($cached);
$secondCall = $controller->getDhlConfig();
expect($secondCall)->toBe($cached);
});
it('flushes the DHL configuration cache on demand', function () {
$reflection = new ReflectionClass(SettingController::class);
$property = $reflection->getProperty('cachedDhlConfig');
$property->setAccessible(true);
$property->setValue(null, ['api_key' => 'cached-api-key']);
expect($property->getValue())->toBe(['api_key' => 'cached-api-key']);
SettingController::flushDhlConfigCache();
expect($property->getValue())->toBeNull();
});