Files
michaelschiemer/tests/debug/test-campaign-discovery.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

136 lines
4.4 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Cache\Driver\InMemoryCache;
use App\Framework\Cache\GeneralCache;
use App\Framework\Core\PathProvider;
use App\Framework\DateTime\SystemClock;
use App\Framework\DI\DefaultContainer;
use App\Framework\Discovery\Factory\DiscoveryServiceFactory;
use App\Framework\Serializer\Php\PhpSerializer;
$basePath = realpath(__DIR__ . '/../..');
echo "=== Campaign Route Discovery Test ===" . PHP_EOL;
echo "Base path: {$basePath}" . PHP_EOL;
echo PHP_EOL;
// Create minimal dependencies
$pathProvider = new PathProvider($basePath);
$clock = new SystemClock();
$cacheDriver = new InMemoryCache();
$serializer = new PhpSerializer();
$cache = new GeneralCache($cacheDriver, $serializer);
// Create container
$container = new DefaultContainer();
// Create factory
$factory = new DiscoveryServiceFactory($container, $pathProvider, $cache, $clock);
// Create discovery service for development (no cache, full paths)
$discovery = $factory->createForDevelopment();
echo "Running discovery..." . PHP_EOL;
$startTime = microtime(true);
$registry = $discovery->discover();
$duration = round((microtime(true) - $startTime) * 1000, 2);
echo "Discovery completed in {$duration}ms" . PHP_EOL;
echo "Total items discovered: " . count($registry) . PHP_EOL;
echo "Files processed: " . $registry->getFileCount() . PHP_EOL;
echo PHP_EOL;
// Get all routes from AttributeRegistry
$routes = $registry->attributes->get(App\Framework\Attributes\Route::class);
echo "Total routes found: " . count($routes) . PHP_EOL;
echo PHP_EOL;
// Filter Campaign routes
echo "=== Looking for Campaign Routes ===" . PHP_EOL;
$campaignRoutes = [];
foreach ($routes as $attr) {
$className = $attr->className->toString();
if (str_contains($className, 'Campaign')) {
$campaignRoutes[] = $attr;
}
}
echo "Campaign routes found: " . count($campaignRoutes) . PHP_EOL;
echo PHP_EOL;
if (count($campaignRoutes) > 0) {
foreach ($campaignRoutes as $attr) {
echo "✅ Route found:" . PHP_EOL;
echo " Class: " . $attr->className->toString() . PHP_EOL;
echo " Method: " . $attr->methodName->toString() . PHP_EOL;
echo " Path: " . $attr->instance->path . PHP_EOL;
echo " HTTP Method: " . $attr->instance->method->value . PHP_EOL;
echo PHP_EOL;
}
} else {
echo "❌ NO CAMPAIGN ROUTES FOUND!" . PHP_EOL;
echo PHP_EOL;
// Debug: Show what was actually discovered
echo "=== All Discovered Routes (first 10) ===" . PHP_EOL;
$count = 0;
foreach ($routes as $attr) {
echo " " . $attr->className->toString() . "::" . $attr->methodName->toString() . PHP_EOL;
echo " Path: " . $attr->instance->path . PHP_EOL;
$count++;
if ($count >= 10) {
echo " ... and " . (count($routes) - 10) . " more" . PHP_EOL;
break;
}
}
}
// Specific check for PreSaveCampaign
echo PHP_EOL . "=== Specific PreSaveCampaign Check ===" . PHP_EOL;
$preSaveFound = false;
foreach ($routes as $attr) {
if ($attr->className->toString() === 'App\\Application\\Campaign\\PreSaveCampaign') {
$preSaveFound = true;
echo "✅ PreSaveCampaign found!" . PHP_EOL;
echo " Path: " . $attr->instance->path . PHP_EOL;
echo " Expected: /campaign/{slug}/presave/{platform}" . PHP_EOL;
break;
}
}
if (! $preSaveFound) {
echo "❌ PreSaveCampaign NOT found in discovery!" . PHP_EOL;
// Check if the file exists
$preSaveFile = $basePath . '/src/Application/Campaign/PreSaveCampaign.php';
echo PHP_EOL . "File exists: " . (file_exists($preSaveFile) ? 'yes' : 'no') . PHP_EOL;
echo "File readable: " . (is_readable($preSaveFile) ? 'yes' : 'no') . PHP_EOL;
// Try to load the class directly
if (class_exists('App\\Application\\Campaign\\PreSaveCampaign')) {
echo "Class can be loaded: yes" . PHP_EOL;
$reflection = new ReflectionClass('App\\Application\\Campaign\\PreSaveCampaign');
$method = $reflection->getMethod('__invoke');
$routeAttrs = $method->getAttributes(Route::class);
echo "Route attributes on __invoke method: " . count($routeAttrs) . PHP_EOL;
if (count($routeAttrs) > 0) {
echo "❌ Route attribute EXISTS but was NOT discovered!" . PHP_EOL;
echo "This indicates a problem with the discovery system!" . PHP_EOL;
}
}
}
echo PHP_EOL . "=== Test Complete ===" . PHP_EOL;