- 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.
123 lines
4.5 KiB
PHP
123 lines
4.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Application\LiveComponents\InfiniteScroll\InfiniteScrollComponent;
|
|
use App\Framework\Core\AppBootstrapper;
|
|
use App\Framework\DateTime\SystemClock;
|
|
use App\Framework\DateTime\SystemHighResolutionClock;
|
|
use App\Framework\LiveComponents\DataProviderResolver;
|
|
use App\Framework\LiveComponents\ValueObjects\ComponentId;
|
|
use App\Framework\Performance\EnhancedPerformanceCollector;
|
|
use App\Framework\Performance\MemoryMonitor;
|
|
|
|
echo "Testing DataProvider Resolution Flow\n";
|
|
echo str_repeat('=', 70) . "\n\n";
|
|
|
|
// 1. Setup Container with Application bootstrap
|
|
echo "1. Setting up Application and Container...\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->bootstrapWeb();
|
|
|
|
// Get container via reflection since getContainer() is not public
|
|
$reflection = new ReflectionObject($bootstrapper);
|
|
$containerProperty = $reflection->getProperty('container');
|
|
$containerProperty->setAccessible(true);
|
|
$container = $containerProperty->getValue($bootstrapper);
|
|
|
|
$resolver = $container->get(DataProviderResolver::class);
|
|
echo "✓ DataProviderResolver obtained from container\n\n";
|
|
|
|
// 2. Initial Render - Create component with DataProviderResolver
|
|
echo "2. Initial Render - Creating component with dataSource='demo'...\n";
|
|
$component = new InfiniteScrollComponent(
|
|
id: ComponentId::fromString('scroll:test'),
|
|
dataProviderResolver: $resolver,
|
|
items: [],
|
|
currentPage: 0,
|
|
pageSize: 5,
|
|
dataSource: 'demo'
|
|
);
|
|
echo "✓ Component created\n";
|
|
|
|
// Verify initial state
|
|
$initialData = $component->getData();
|
|
echo " - Initial state captured: " . count($initialData->toArray()) . " fields\n";
|
|
echo " - dataSource in state: " . $initialData->get('data_source') . "\n\n";
|
|
|
|
// 3. Execute Action - loadMore
|
|
echo "3. Executing Action - loadMore()...\n";
|
|
$actionResult = $component->loadMore();
|
|
echo "✓ Action executed\n";
|
|
|
|
$items = $actionResult->get('items');
|
|
echo " - Items loaded: " . count($items) . "\n";
|
|
echo " - Current page: " . $actionResult->get('current_page') . "\n";
|
|
echo " - dataSource preserved: " . $actionResult->get('data_source') . "\n\n";
|
|
|
|
// 4. State Restoration - Reconstruct component from action result
|
|
echo "4. State Restoration - Reconstructing component from ComponentData...\n";
|
|
$restoredComponent = new InfiniteScrollComponent(
|
|
id: ComponentId::fromString('scroll:test'),
|
|
dataProviderResolver: $resolver,
|
|
initialData: $actionResult // Framework path - state restoration
|
|
);
|
|
echo "✓ Component restored from state\n";
|
|
|
|
// Verify restored state
|
|
$restoredData = $restoredComponent->getData();
|
|
echo " - Restored items count: " . count($restoredData->get('items')) . "\n";
|
|
echo " - Restored page: " . $restoredData->get('current_page') . "\n";
|
|
echo " - Restored dataSource: " . $restoredData->get('data_source') . "\n\n";
|
|
|
|
// 5. Execute another action on restored component
|
|
echo "5. Executing Action on Restored Component - loadMore()...\n";
|
|
$secondActionResult = $restoredComponent->loadMore();
|
|
echo "✓ Action executed on restored component\n";
|
|
|
|
$secondItems = $secondActionResult->get('items');
|
|
echo " - Total items now: " . count($secondItems) . "\n";
|
|
echo " - Current page: " . $secondActionResult->get('current_page') . "\n";
|
|
echo " - dataSource still preserved: " . $secondActionResult->get('data_source') . "\n\n";
|
|
|
|
// 6. Verify data integrity
|
|
echo "6. Verifying Data Integrity...\n";
|
|
$allCorrect = true;
|
|
|
|
if ($secondActionResult->get('data_source') !== 'demo') {
|
|
echo "✗ ERROR: dataSource not preserved through state restoration!\n";
|
|
$allCorrect = false;
|
|
} else {
|
|
echo "✓ dataSource preserved correctly\n";
|
|
}
|
|
|
|
if ($secondActionResult->get('current_page') !== 2) {
|
|
echo "✗ ERROR: page count incorrect after second loadMore!\n";
|
|
$allCorrect = false;
|
|
} else {
|
|
echo "✓ Page count correct (2)\n";
|
|
}
|
|
|
|
if (count($secondItems) !== 10) {
|
|
echo "✗ ERROR: Expected 10 items (5 per page * 2 pages), got " . count($secondItems) . "\n";
|
|
$allCorrect = false;
|
|
} else {
|
|
echo "✓ Item count correct (10 items)\n";
|
|
}
|
|
|
|
echo "\n" . str_repeat('=', 70) . "\n";
|
|
if ($allCorrect) {
|
|
echo "✓ All tests PASSED - DataProvider resolution works correctly!\n";
|
|
exit(0);
|
|
} else {
|
|
echo "✗ Some tests FAILED - Check errors above\n";
|
|
exit(1);
|
|
}
|