Files
michaelschiemer/tests/debug/test-complete-svg-rendering.php
Michael Schiemer 95147ff23e refactor(deployment): Remove WireGuard VPN dependency and restore public service access
Remove WireGuard integration from production deployment to simplify infrastructure:
- Remove docker-compose-direct-access.yml (VPN-bound services)
- Remove VPN-only middlewares from Grafana, Prometheus, Portainer
- Remove WireGuard middleware definitions from Traefik
- Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers

All monitoring services now publicly accessible via subdomains:
- grafana.michaelschiemer.de (with Grafana native auth)
- prometheus.michaelschiemer.de (with Basic Auth)
- portainer.michaelschiemer.de (with Portainer native auth)

All services use Let's Encrypt SSL certificates via Traefik.
2025-11-05 12:48:25 +01:00

187 lines
5.4 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\QrCode\QrCodeGenerator;
use App\Framework\QrCode\QrCodeRenderer;
use App\Framework\QrCode\ValueObjects\ErrorCorrectionLevel;
use App\Framework\QrCode\ValueObjects\QrCodeConfig;
use App\Framework\QrCode\ValueObjects\QrCodeVersion;
use App\Framework\QrCode\ValueObjects\EncodingMode;
use App\Framework\QrCode\ValueObjects\QrCodeStyle;
echo "=== Complete SVG Rendering Verification ===\n\n";
$config = new QrCodeConfig(
version: QrCodeVersion::fromNumber(1),
errorCorrectionLevel: ErrorCorrectionLevel::M,
encodingMode: EncodingMode::BYTE
);
$matrix = QrCodeGenerator::generate('HELLO', $config);
$size = $matrix->getSize();
echo "Matrix: {$size}x{$size}\n\n";
// Count dark modules in matrix
$darkCount = 0;
for ($row = 0; $row < $size; $row++) {
for ($col = 0; $col < $size; $col++) {
if ($matrix->getModuleAt($row, $col)->isDark()) {
$darkCount++;
}
}
}
echo "Dark modules in matrix: {$darkCount}\n";
// Render SVG
$style = QrCodeStyle::large();
$renderer = new QrCodeRenderer();
$svg = $renderer->renderCustom($matrix, $style, false);
// Count rectangles in SVG
preg_match_all('/<rect[^>]*fill="black"/', $svg, $matches);
$svgRectCount = count($matches[0]);
echo "Black rectangles in SVG: {$svgRectCount}\n";
if ($darkCount === $svgRectCount) {
echo "✅ All dark modules are rendered\n\n";
} else {
echo "❌ Mismatch! Missing " . ($darkCount - $svgRectCount) . " rectangles\n\n";
}
// Verify finder patterns are complete
echo "=== Finder Pattern Completeness ===\n";
$finderPositions = [
['name' => 'Top-Left', 'startRow' => 0, 'startCol' => 0],
['name' => 'Top-Right', 'startRow' => 0, 'startCol' => 14],
['name' => 'Bottom-Left', 'startRow' => 14, 'startCol' => 0],
];
foreach ($finderPositions as $finder) {
$expectedDark = 0;
$actualDark = 0;
for ($r = 0; $r < 7; $r++) {
for ($c = 0; $c < 7; $c++) {
$row = $finder['startRow'] + $r;
$col = $finder['startCol'] + $c;
if ($matrix->getModuleAt($row, $col)->isDark()) {
$expectedDark++;
// Check if rendered in SVG
$x = 80 + $col * 20;
$y = 80 + $row * 20;
if (preg_match('/<rect x="' . $x . '\.00" y="' . $y . '\.00" width="20" height="20" fill="black"/', $svg)) {
$actualDark++;
}
}
}
}
echo "{$finder['name']}: {$actualDark}/{$expectedDark} modules rendered\n";
if ($actualDark === $expectedDark) {
echo " ✅ Complete\n";
} else {
echo " ❌ Missing " . ($expectedDark - $actualDark) . " modules\n";
}
}
// Check timing patterns
echo "\n=== Timing Pattern Completeness ===\n";
// Horizontal timing (row 6, cols 8-12)
$timingDark = 0;
$timingRendered = 0;
for ($col = 8; $col < 13; $col++) {
if ($matrix->getModuleAt(6, $col)->isDark()) {
$timingDark++;
$x = 80 + $col * 20;
$y = 80 + 6 * 20;
if (preg_match('/<rect x="' . $x . '\.00" y="' . $y . '\.00" width="20" height="20" fill="black"/', $svg)) {
$timingRendered++;
}
}
}
echo "Horizontal timing: {$timingRendered}/{$timingDark} modules rendered\n";
// Vertical timing (col 6, rows 8-12)
$vTimingDark = 0;
$vTimingRendered = 0;
for ($row = 8; $row < 13; $row++) {
if ($matrix->getModuleAt($row, 6)->isDark()) {
$vTimingDark++;
$x = 80 + 6 * 20;
$y = 80 + $row * 20;
if (preg_match('/<rect x="' . $x . '\.00" y="' . $y . '\.00" width="20" height="20" fill="black"/', $svg)) {
$vTimingRendered++;
}
}
}
echo "Vertical timing: {$vTimingRendered}/{$vTimingDark} modules rendered\n";
// Check format information
echo "\n=== Format Information Completeness ===\n";
$formatCols = [0, 1, 2, 3, 4, 5, 7, 8, 20, 19, 18, 17, 16, 15, 14];
$formatDark = 0;
$formatRendered = 0;
foreach ($formatCols as $col) {
if ($matrix->getModuleAt(8, $col)->isDark()) {
$formatDark++;
$x = 80 + $col * 20;
$y = 80 + 8 * 20;
if (preg_match('/<rect x="' . $x . '\.00" y="' . $y . '\.00" width="20" height="20" fill="black"/', $svg)) {
$formatRendered++;
}
}
}
echo "Format info (horizontal): {$formatRendered}/{$formatDark} modules rendered\n";
$formatRows = [20, 19, 18, 17, 16, 15, 14, 8, 7, 5, 4, 3, 2, 1, 0];
$formatVDark = 0;
$formatVRendered = 0;
foreach ($formatRows as $row) {
if ($matrix->getModuleAt($row, 8)->isDark()) {
$formatVDark++;
$x = 80 + 8 * 20;
$y = 80 + $row * 20;
if (preg_match('/<rect x="' . $x . '\.00" y="' . $y . '\.00" width="20" height="20" fill="black"/', $svg)) {
$formatVRendered++;
}
}
}
echo "Format info (vertical): {$formatVRendered}/{$formatVDark} modules rendered\n";
// Generate a visual ASCII representation
echo "\n=== Visual Matrix Check ===\n";
echo "Top-left corner (10x10):\n";
for ($row = 0; $row < 10; $row++) {
echo " ";
for ($col = 0; $col < 10; $col++) {
$isDark = $matrix->getModuleAt($row, $col)->isDark();
echo $isDark ? '█' : '░';
}
echo "\n";
}
// Save SVG for inspection
$filepath = __DIR__ . '/test-qrcodes/complete-verification.svg';
file_put_contents($filepath, $svg);
echo "\n✅ Saved complete SVG: {$filepath}\n";