<?php

echo "=== Testing Mask Pattern 2 (column % 3 == 0) ===\n\n";

// Manual calculation for Pattern 2
echo "Expected behavior for Pattern 2:\n";
echo "Columns 0, 3, 6, 9, 12, 15, 18 should be inverted\n";
echo "All other columns should NOT be inverted\n\n";

require_once __DIR__ . '/../../vendor/autoload.php';

use App\Framework\QrCode\Masking\MaskPattern;

$pattern = MaskPattern::PATTERN_2;

// Test critical columns
$testCols = [0, 1, 2, 3, 6, 8, 9, 12, 15, 18, 20];

echo "Testing shouldInvert() for various columns (row=10):\n";
foreach ($testCols as $col) {
    $shouldInvert = $pattern->shouldInvert(10, $col);
    $expected = ($col % 3 === 0);
    $match = $shouldInvert === $expected ? "✅" : "❌";
    
    echo sprintf(
        "  Col %2d: mod=%d, shouldInvert=%s, expected=%s %s\n",
        $col, $col % 3,
        $shouldInvert ? 'true ' : 'false',
        $expected ? 'true ' : 'false',
        $match
    );
}

echo "\n✅ Mask Pattern 2 logic is correct!\n";

