From 34eac52200b024cd75c8329a3c0d2d7a86aa6855 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Fri, 2 Oct 2026 21:10:21 +0200 Subject: [PATCH 1/2] fix(archimate): stop writing every exported model to /tmp/debug_export.xml --- lib/Service/ArchiMateExportService.php | 5 ---- .../ArchiMateExportNoDebugDumpTest.php | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php diff --git a/lib/Service/ArchiMateExportService.php b/lib/Service/ArchiMateExportService.php index ac3654009..202a9cff4 100644 --- a/lib/Service/ArchiMateExportService.php +++ b/lib/Service/ArchiMateExportService.php @@ -2143,11 +2143,6 @@ private function reconstructNestedXmlStructure(array $archiMateData): array { private function runQualityAssuranceChecks(string $xmlString): void { $this->logger->info('Running Quality Assurance checks on exported XML'); - // DEBUG: Save XML to file for inspection. - $debugPath = '/tmp/debug_export.xml'; - file_put_contents($debugPath, $xmlString); - $this->logger->info('DEBUG: Raw XML saved to ' . $debugPath . ' (size: ' . strlen($xmlString) . ' bytes)'); - try { $xml = new \SimpleXMLElement($xmlString); diff --git a/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php b/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php new file mode 100644 index 000000000..17ccf0bb4 --- /dev/null +++ b/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php @@ -0,0 +1,30 @@ + + * SPDX-License-Identifier: EUPL-1.2 + */ + +declare(strict_types=1); + +namespace OCA\Stackiq\Tests\Unit\Service; + +use PHPUnit\Framework\TestCase; + +/** + * A leftover debug line wrote every exported model to `/tmp/debug_export.xml`: + * a fixed name in a folder every process on the host can read, and logged at + * info level. The export is returned to the caller; it must not leave a copy. + */ +class ArchiMateExportNoDebugDumpTest extends TestCase { + + public function testTheExportServiceWritesNoFile(): void { + $code = (string)file_get_contents(dirname(__DIR__, 3) . '/lib/Service/ArchiMateExportService.php'); + $code = (string)preg_replace('#/\*.*?\*/|//[^\n]*#s', '', $code); + + $this->assertStringNotContainsString('debug_export', $code); + $this->assertSame(0, preg_match('/\bfile_put_contents\s*\(|\bfopen\s*\(/', $code), 'the export returns its XML and writes no file'); + } +} From 859210265f890764244ba51a3987bf50ec1f9262 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Fri, 2 Oct 2026 21:22:04 +0200 Subject: [PATCH 2/2] test(archimate): named arguments and the spec tag --- lib/Service/ArchiMateExportService.php | 2 ++ .../ArchiMateExportNoDebugDumpTest.php | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/Service/ArchiMateExportService.php b/lib/Service/ArchiMateExportService.php index 202a9cff4..f94410edb 100644 --- a/lib/Service/ArchiMateExportService.php +++ b/lib/Service/ArchiMateExportService.php @@ -53,6 +53,8 @@ * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) * @SuppressWarnings(PHPMD.CamelCaseParameterName) + * + * @spec openspec/specs/archimate-export/spec.md */ class ArchiMateExportService { /** diff --git a/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php b/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php index 17ccf0bb4..801b4064f 100644 --- a/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php +++ b/tests/Unit/Service/ArchiMateExportNoDebugDumpTest.php @@ -20,11 +20,22 @@ */ class ArchiMateExportNoDebugDumpTest extends TestCase { + /** + * The service source holds no file write and no debug dump path. + * + * @return void + * + * @spec openspec/specs/archimate-export/spec.md + */ public function testTheExportServiceWritesNoFile(): void { - $code = (string)file_get_contents(dirname(__DIR__, 3) . '/lib/Service/ArchiMateExportService.php'); - $code = (string)preg_replace('#/\*.*?\*/|//[^\n]*#s', '', $code); + $code = (string)file_get_contents(filename: dirname(path: __DIR__, levels: 3) . '/lib/Service/ArchiMateExportService.php'); + $code = (string)preg_replace(pattern: '#/\*.*?\*/|//[^\n]*#s', replacement: '', subject: $code); - $this->assertStringNotContainsString('debug_export', $code); - $this->assertSame(0, preg_match('/\bfile_put_contents\s*\(|\bfopen\s*\(/', $code), 'the export returns its XML and writes no file'); + $this->assertStringNotContainsString(needle: 'debug_export', haystack: $code); + $this->assertSame( + expected: 0, + actual: preg_match(pattern: '/\bfile_put_contents\s*\(|\bfopen\s*\(/', subject: $code), + message: 'the export returns its XML and writes no file' + ); } }