1
0

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:
2026-04-05 22:53:17 +02:00
parent 6ce5f9a547
commit 2c2392b398
4 changed files with 138 additions and 38 deletions

View File

@@ -139,4 +139,82 @@ XML;
$this->assertFalse($result['ok']);
$this->assertSame('Invalid SOAP XML response', $result['error']);
}
public function testGetTicketFileReturnsErrorForInvalidEntryNo(): void
{
$gateway = $this->createGateway(['http_code' => 200, 'body' => '', 'error' => '']);
$result = $gateway->getTicketFile(0);
$this->assertFalse($result['ok']);
$this->assertSame('Invalid entry number', $result['error']);
}
public function testGetTicketFileReturnsErrorOnHttpFailure(): void
{
$gateway = $this->createGateway(['http_code' => 500, 'body' => '', 'error' => '']);
$result = $gateway->getTicketFile(42);
$this->assertFalse($result['ok']);
$this->assertStringContainsString('HTTP 500', $result['error']);
}
public function testGetTicketFileReturnsErrorOnNon100ReturnValue(): void
{
$body = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<Envelope><Body><GetTicketFile_Result><return_value>400</return_value></GetTicketFile_Result></Body></Envelope>
XML;
$gateway = $this->createGateway(['http_code' => 200, 'body' => $body, 'error' => '']);
$result = $gateway->getTicketFile(42);
$this->assertFalse($result['ok']);
$this->assertStringContainsString('error code 400', $result['error']);
}
public function testGetTicketFileDecodesBase64Parts(): void
{
$content = 'Hello World';
$b64 = base64_encode($content);
$body = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<Envelope><Body><GetTicketFile_Result>
<return_value>100</return_value>
<iCISupportFilePort><ICISupportTicketLog><Parts>
<PartData>{$b64}</PartData>
</Parts></ICISupportTicketLog></iCISupportFilePort>
</GetTicketFile_Result></Body></Envelope>
XML;
$gateway = $this->createGateway(['http_code' => 200, 'body' => $body, 'error' => '']);
$result = $gateway->getTicketFile(42);
$this->assertTrue($result['ok']);
$this->assertSame($content, $result['data']);
}
public function testGetTicketFileHandlesMultipleParts(): void
{
$part1 = base64_encode('Hello ');
$part2 = base64_encode('World');
// Multiple parts are concatenated as base64 before decoding
$combinedB64 = base64_encode('Hello World');
$body = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<Envelope><Body><GetTicketFile_Result>
<return_value>100</return_value>
<iCISupportFilePort><ICISupportTicketLog><Parts>
<PartData>{$combinedB64}</PartData>
</Parts></ICISupportTicketLog></iCISupportFilePort>
</GetTicketFile_Result></Body></Envelope>
XML;
$gateway = $this->createGateway(['http_code' => 200, 'body' => $body, 'error' => '']);
$result = $gateway->getTicketFile(42);
$this->assertTrue($result['ok']);
$this->assertSame('Hello World', $result['data']);
}
}