- 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.
109 lines
3.8 KiB
PHP
109 lines
3.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\Core\RouteCompiler;
|
|
use App\Framework\Core\ValueObjects\ClassName;
|
|
use App\Framework\Core\ValueObjects\MethodName;
|
|
use App\Framework\Discovery\ValueObjects\DiscoveredAttribute;
|
|
use App\Framework\Http\HttpRequest;
|
|
use App\Framework\Http\Method;
|
|
use App\Framework\Router\HttpRouter;
|
|
|
|
echo "=== Multi-Parameter Route Testing ===" . PHP_EOL . PHP_EOL;
|
|
|
|
// Test 1: Route Compilation with Multiple Parameters
|
|
echo "Test 1: Kompiliere Route mit mehreren Parametern" . PHP_EOL;
|
|
|
|
$discoveredRoute = new DiscoveredAttribute(
|
|
attributeClass: Route::class,
|
|
className: ClassName::create('TestController'),
|
|
methodName: MethodName::create('handleCampaign'),
|
|
arguments: [
|
|
'path' => '/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;
|