27-05-2026 DHL Modul v2.1 / Optimierung tracking
This commit is contained in:
parent
036595be94
commit
2bdc9ada3c
33 changed files with 2367 additions and 2086 deletions
47
tests/Unit/Dhl/DhlConfigCachingTest.php
Normal file
47
tests/Unit/Dhl/DhlConfigCachingTest.php
Normal 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();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue