'/campaign/{slug}/presave/{platform}', 'method' => Method::GET ], additionalData: [ 'parameters' => [ ['name' => 'slug', 'type' => 'string', 'isBuiltin' => true, 'hasDefault' => false], ['name' => 'platform', 'type' => 'string', 'isBuiltin' => true, 'hasDefault' => false] ] ] ); $compiler = new RouteCompiler(); $compiled = $compiler->compile($discoveredRoute); echo "Compiled Routes: " . print_r(array_keys($compiled), true) . PHP_EOL; if (isset($compiled['GET']['default']['dynamic'][0])) { $route = $compiled['GET']['default']['dynamic'][0]; echo "✅ Route erfolgreich kompiliert" . PHP_EOL; echo " Path: " . $route->path . PHP_EOL; echo " Regex: " . $route->regex . PHP_EOL; echo " Param Names: " . print_r($route->paramNames, true) . PHP_EOL; // Test 2: Regex Matching echo PHP_EOL . "Test 2: Teste Regex Matching" . PHP_EOL; $testPath = '/campaign/test-campaign/presave/spotify'; if (preg_match($route->regex, $testPath, $matches)) { echo "✅ Path matched Regex!" . PHP_EOL; echo " Matches: " . print_r($matches, true) . PHP_EOL; // Extract parameter values $paramValues = []; foreach ($route->paramNames as $index => $paramName) { // Parameter values start at index 1 (index 0 is full match) $paramValues[$paramName] = $matches[$index + 1] ?? null; } echo " Extracted Parameters: " . print_r($paramValues, true) . PHP_EOL; if ($paramValues['slug'] === 'test-campaign' && $paramValues['platform'] === 'spotify') { echo "✅ Parameter extraction korrekt!" . PHP_EOL; } else { echo "❌ Parameter extraction fehlgeschlagen" . PHP_EOL; } } else { echo "❌ Path matched NICHT!" . PHP_EOL; echo " Expected Pattern: " . $route->regex . PHP_EOL; echo " Test Path: " . $testPath . PHP_EOL; } } else { echo "❌ Keine dynamic Route gefunden" . PHP_EOL; } // Test 3: Full Router Integration Test echo PHP_EOL . "Test 3: Full HttpRouter Integration" . PHP_EOL; $compiledRoutes = $compiler->compileOptimized($discoveredRoute); $router = new HttpRouter($compiledRoutes); $request = new HttpRequest( method: Method::GET, path: '/campaign/test-campaign/presave/spotify' ); $context = $router->match($request); if ($context->isSuccess()) { echo "✅ Router matched route successfully!" . PHP_EOL; echo " Matched Route Path: " . $context->match->route->path . PHP_EOL; if ($context->match->route instanceof \App\Framework\Core\DynamicRoute) { echo " Route Type: Dynamic" . PHP_EOL; echo " Param Values: " . print_r($context->match->route->paramValues, true) . PHP_EOL; } } else { echo "❌ Router konnte Route NICHT matchen" . PHP_EOL; echo " Path: " . $context->path . PHP_EOL; } echo PHP_EOL . "=== Test Summary ===" . PHP_EOL; echo "Routes mit mehreren Parametern funktionieren grundsätzlich: "; echo ($context->isSuccess() ? "✅ JA" : "❌ NEIN") . PHP_EOL;