Files
michaelschiemer/tests/debug/test-mask-application.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

84 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\QrCode\Masking\MaskPattern;
use App\Framework\QrCode\ValueObjects\Module;
use App\Framework\QrCode\ValueObjects\QrCodeMatrix;
echo "=== Testing Mask Pattern 2 Application ===\n\n";
// Mask Pattern 2: (row + column) % 3 == 0
echo "Mask Pattern 2 formula: (row + column) % 3 == 0\n\n";
$pattern = MaskPattern::PATTERN_2;
// Test a few positions
$testPositions = [
[0, 0], // 0+0=0, 0%3=0 → should invert
[0, 1], // 0+1=1, 1%3=1 → should NOT invert
[0, 2], // 0+2=2, 2%3=2 → should NOT invert
[1, 2], // 1+2=3, 3%3=0 → should invert
[10, 11], // 10+11=21, 21%3=0 → should invert
[10, 12], // 10+12=22, 22%3=1 → should NOT invert
];
echo "Testing shouldInvert() at various positions:\n";
foreach ($testPositions as [$row, $col]) {
$sum = $row + $col;
$mod = $sum % 3;
$shouldInvert = $pattern->shouldInvert($row, $col);
$expected = ($mod === 0);
$match = $shouldInvert === $expected ? "" : "";
echo sprintf(
" (%2d,%2d): sum=%2d, mod=%d, shouldInvert=%s, expected=%s %s\n",
$row, $col, $sum, $mod,
$shouldInvert ? 'true ' : 'false',
$expected ? 'true ' : 'false',
$match
);
}
echo "\n";
// Test actual mask application
echo "Testing actual mask application on a small matrix:\n";
$matrix = new QrCodeMatrix(5);
// Set all modules to light initially
for ($r = 0; $r < 5; $r++) {
for ($c = 0; $c < 5; $c++) {
$matrix = $matrix->setModuleAt($r, $c, Module::light());
}
}
// Now apply mask to check which modules get inverted
for ($r = 0; $r < 5; $r++) {
for ($c = 0; $c < 5; $c++) {
if ($pattern->shouldInvert($r, $c)) {
$matrix = $matrix->setModuleAt($r, $c, Module::dark());
}
}
}
// Display result
echo "Mask pattern (1 = inverted, 0 = not inverted):\n";
for ($r = 0; $r < 5; $r++) {
echo " ";
for ($c = 0; $c < 5; $c++) {
echo $matrix->getModuleAt($r, $c)->isDark() ? '1' : '0';
}
echo "\n";
}
echo "\nExpected pattern:\n";
echo " 10010\n";
echo " 01001\n";
echo " 00100\n";
echo " 10010\n";
echo " 01001\n";