fix(helpdesk): address code review findings for ticket files
- Use Router::download() instead of die() to avoid Analyzer rejection - Add 5 PHPUnit tests for BcSoapGateway::getTicketFile() (F-001) - Add test for file metadata on communication entries (F-002) - Add rel=noopener noreferrer on target=_blank links (F-003) - Add aria-hidden on download icon, aria-label on image link (F-003) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -279,4 +279,61 @@ class TicketCommunicationServiceTest extends TestCase
|
||||
$this->assertNotEmpty($result['entries']);
|
||||
$this->assertSame('Felix Schneider', $result['entries'][0]['actor']);
|
||||
}
|
||||
|
||||
public function testFileTypeEntriesIncludeFileMetadata(): void
|
||||
{
|
||||
$soapGateway = $this->createMock(BcSoapGateway::class);
|
||||
$soapGateway->method('getTicketCommunicationText')->willReturn([
|
||||
'ok' => false,
|
||||
'soap_used' => false,
|
||||
'return_value' => 0,
|
||||
'communication_text' => '',
|
||||
'message_entries' => '',
|
||||
]);
|
||||
|
||||
$odataGateway = $this->createMock(BcODataGateway::class);
|
||||
$odataGateway->method('getTicketLog')->willReturn([
|
||||
[
|
||||
'Entry_No' => 42,
|
||||
'Created_By' => 'NKS',
|
||||
'Created_By_Type' => 'Benutzer',
|
||||
'Creation_Date' => '2026-04-03',
|
||||
'Creation_Time' => '10:00:00.000',
|
||||
'Type' => 'Datei',
|
||||
'State_Subtype' => '',
|
||||
'Record_ID' => 'screenshot.png',
|
||||
],
|
||||
[
|
||||
'Entry_No' => 41,
|
||||
'Created_By' => 'NKS',
|
||||
'Created_By_Type' => 'Benutzer',
|
||||
'Creation_Date' => '2026-04-03',
|
||||
'Creation_Time' => '09:55:00.000',
|
||||
'Type' => 'Status',
|
||||
'State_Subtype' => 'Offen',
|
||||
'Record_ID' => 'ICI Support Ticket: T26-1216',
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new TicketCommunicationService($soapGateway, $odataGateway);
|
||||
$result = $service->loadTicketCommunicationFeed('T26-1216', 40);
|
||||
|
||||
$this->assertTrue($result['ok']);
|
||||
$entries = $result['entries'];
|
||||
|
||||
// Find the file entry
|
||||
$fileEntries = array_values(array_filter($entries, static fn (array $e) => ($e['type_variant'] ?? '') === 'file'));
|
||||
$this->assertNotEmpty($fileEntries, 'Should have at least one file entry');
|
||||
|
||||
$fileEntry = $fileEntries[0];
|
||||
$this->assertSame('42', $fileEntry['file_entry_no']);
|
||||
$this->assertSame('screenshot.png', $fileEntry['file_name']);
|
||||
|
||||
// Non-file entries should have empty file fields
|
||||
$statusEntries = array_values(array_filter($entries, static fn (array $e) => ($e['type_variant'] ?? '') === 'status'));
|
||||
if ($statusEntries !== []) {
|
||||
$this->assertSame('', $statusEntries[0]['file_entry_no']);
|
||||
$this->assertSame('', $statusEntries[0]['file_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user