forked from fa/breadcrumb-the-shire
feat(helpdesk): add dashboards, communication feed, settings UI and fix routing
Add support/sales/controlling dashboards with KPIs, trend charts and risk indicators. Add debitor communication timeline, contact filters, system recommendations engine, and configurable controlling risk rules. Rename search→index to fix query-string preservation on back navigation. Remove fake escalation rate metric, add KPI info tooltips, and switch trend chart colors to red (created) / green (closed) for clarity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Module\Helpdesk\Service;
|
||||
|
||||
use MintyPHP\Http\SessionStoreInterface;
|
||||
use MintyPHP\Module\Helpdesk\Service\DebitorCacheControl;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DebitorCacheControlTest extends TestCase
|
||||
{
|
||||
public function testParseRefreshFlagRecognizesTruthyValues(): void
|
||||
{
|
||||
$this->assertTrue(DebitorCacheControl::parseRefreshFlag('1'));
|
||||
$this->assertTrue(DebitorCacheControl::parseRefreshFlag('true'));
|
||||
$this->assertTrue(DebitorCacheControl::parseRefreshFlag('YES'));
|
||||
$this->assertTrue(DebitorCacheControl::parseRefreshFlag(true));
|
||||
}
|
||||
|
||||
public function testParseRefreshFlagReturnsFalseForNonTruthyValues(): void
|
||||
{
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag(''));
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag('0'));
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag('false'));
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag('nope'));
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag(false));
|
||||
$this->assertFalse(DebitorCacheControl::parseRefreshFlag(null));
|
||||
}
|
||||
|
||||
public function testResolveTenantScopeUsesTenantIdOrGlobal(): void
|
||||
{
|
||||
$this->assertSame('9', DebitorCacheControl::resolveTenantScope([
|
||||
'current_tenant' => ['id' => 9],
|
||||
]));
|
||||
|
||||
$this->assertSame('global', DebitorCacheControl::resolveTenantScope([]));
|
||||
}
|
||||
|
||||
public function testInvalidateDebitorCachesRemovesDebitorAndTenantSharedKeys(): void
|
||||
{
|
||||
$sessionStore = $this->createMock(SessionStoreInterface::class);
|
||||
$sessionStore->expects($this->exactly(13))
|
||||
->method('remove')
|
||||
->with($this->callback(static function (string $key): bool {
|
||||
return str_contains($key, '.13.10259')
|
||||
|| $key === 'module.helpdesk.debitor.v1.escalation-definitions.13';
|
||||
}));
|
||||
|
||||
DebitorCacheControl::invalidateDebitorCaches($sessionStore, '13', '10259', true);
|
||||
}
|
||||
|
||||
public function testContractLinesKeyFormat(): void
|
||||
{
|
||||
$key = DebitorCacheControl::contractLinesKey('5', '10254');
|
||||
$this->assertSame('module.helpdesk.debitor.v2.contract-lines.5.10254', $key);
|
||||
}
|
||||
|
||||
public function testAllDebitorCacheKeysIncludesContractLinesKey(): void
|
||||
{
|
||||
$keys = DebitorCacheControl::allDebitorCacheKeys('5', '10254');
|
||||
$this->assertContains('module.helpdesk.debitor.v2.contract-lines.5.10254', $keys);
|
||||
}
|
||||
|
||||
public function testControllingTicketsKeyFormat(): void
|
||||
{
|
||||
$key = DebitorCacheControl::controllingTicketsKey('7', '10610');
|
||||
$this->assertSame('module.helpdesk.debitor.v2.controlling-tickets.7.10610', $key);
|
||||
}
|
||||
|
||||
public function testAllDebitorCacheKeysIncludesControllingKey(): void
|
||||
{
|
||||
$keys = DebitorCacheControl::allDebitorCacheKeys('7', '10610');
|
||||
$this->assertContains('module.helpdesk.debitor.v2.controlling-tickets.7.10610', $keys);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user