- 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.
125 lines
4.3 KiB
PHP
125 lines
4.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Application\LiveComponents\Services\ChartDataProvider;
|
|
use App\Framework\Core\AppBootstrapper;
|
|
use App\Framework\DateTime\SystemClock;
|
|
use App\Framework\DateTime\SystemHighResolutionClock;
|
|
use App\Framework\LiveComponents\DataProviderResolver;
|
|
use App\Framework\Performance\EnhancedPerformanceCollector;
|
|
use App\Framework\Performance\MemoryMonitor;
|
|
|
|
echo "\nDataProvider Production Test\n";
|
|
echo str_repeat('=', 70) . "\n\n";
|
|
|
|
// 1. Bootstrap Application
|
|
echo "1. Bootstrapping Application...\n";
|
|
$basePath = dirname(__DIR__, 2);
|
|
$clock = new SystemClock();
|
|
$highResClock = new SystemHighResolutionClock();
|
|
$memoryMonitor = new MemoryMonitor();
|
|
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
|
|
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
|
$app = $bootstrapper->bootstrapConsole();
|
|
echo "✓ Application bootstrapped\n\n";
|
|
|
|
// 2. Get DataProviderResolver from Container
|
|
echo "2. Getting DataProviderResolver from Container...\n";
|
|
|
|
try {
|
|
$resolver = $app->getContainer()->get(DataProviderResolver::class);
|
|
echo "✓ DataProviderResolver resolved from container\n\n";
|
|
} catch (\Exception $e) {
|
|
echo "✗ FAILED: " . $e->getMessage() . "\n";
|
|
echo " This means DataProviderResolverInitializer is not working\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
// 3. Test Resolve ChartDataProvider with 'demo' name
|
|
echo "3. Resolving ChartDataProvider with name 'demo'...\n";
|
|
|
|
try {
|
|
$provider = $resolver->resolve(ChartDataProvider::class, 'demo');
|
|
|
|
if ($provider === null) {
|
|
echo "✗ FAILED: Provider returned null\n";
|
|
echo " This means either:\n";
|
|
echo " - DemoChartDataProvider is not discovered\n";
|
|
echo " - DemoChartDataProvider is not registered in Container\n";
|
|
echo " - Attribute arguments are not correct\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
echo "✓ Provider resolved: " . get_class($provider) . "\n";
|
|
echo " Instance type: " . ($provider instanceof ChartDataProvider ? 'Valid' : 'Invalid') . "\n\n";
|
|
} catch (\Exception $e) {
|
|
echo "✗ FAILED: " . $e->getMessage() . "\n";
|
|
echo " File: " . $e->getFile() . ":" . $e->getLine() . "\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
// 4. Test getData() method
|
|
echo "4. Testing getData() method on resolved provider...\n";
|
|
|
|
try {
|
|
$data = $provider->getData(['page' => 1, 'pageSize' => 5]);
|
|
|
|
echo "✓ getData() executed successfully\n";
|
|
echo " Data points returned: " . count($data) . "\n";
|
|
echo " Sample data: " . json_encode(array_slice($data, 0, 2)) . "\n\n";
|
|
} catch (\Exception $e) {
|
|
echo "✗ FAILED: " . $e->getMessage() . "\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
// 5. Test getAvailableProviders()
|
|
echo "5. Testing getAvailableProviders()...\n";
|
|
|
|
try {
|
|
$availableProviders = $resolver->getAvailableProviders(ChartDataProvider::class);
|
|
|
|
echo "✓ Available providers: " . implode(', ', $availableProviders) . "\n";
|
|
echo " Count: " . count($availableProviders) . "\n\n";
|
|
} catch (\Exception $e) {
|
|
echo "✗ FAILED: " . $e->getMessage() . "\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
// 6. Test has() method
|
|
echo "6. Testing has() method...\n";
|
|
$hasDemoProvider = $resolver->has(ChartDataProvider::class, 'demo');
|
|
$hasInvalidProvider = $resolver->has(ChartDataProvider::class, 'nonexistent');
|
|
|
|
echo " has('demo'): " . ($hasDemoProvider ? 'true' : 'false') . "\n";
|
|
echo " has('nonexistent'): " . ($hasInvalidProvider ? 'true' : 'false') . "\n\n";
|
|
|
|
if (! $hasDemoProvider) {
|
|
echo "✗ FAILED: has() should return true for 'demo'\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
if ($hasInvalidProvider) {
|
|
echo "✗ FAILED: has() should return false for 'nonexistent'\n\n";
|
|
exit(1);
|
|
}
|
|
|
|
echo "✓ has() works correctly\n\n";
|
|
|
|
// Summary
|
|
echo str_repeat('=', 70) . "\n";
|
|
echo "✅ ALL PRODUCTION TESTS PASSED\n\n";
|
|
|
|
echo "Summary:\n";
|
|
echo "- DataProviderResolver is correctly registered in Container ✓\n";
|
|
echo "- DataProvider implementations are correctly registered ✓\n";
|
|
echo "- Discovery system finds DataProvider attributes ✓\n";
|
|
echo "- Provider resolution works correctly ✓\n";
|
|
echo "- Provider methods execute successfully ✓\n";
|
|
echo "- getAvailableProviders() works correctly ✓\n";
|
|
echo "- has() method works correctly ✓\n\n";
|
|
|
|
echo "Next step: Test in actual web request with ChartComponent\n";
|