- 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.
74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\StateManagement\InMemoryStateManager;
|
|
use App\Framework\Core\ValueObjects\Duration;
|
|
use App\Application\LiveComponents\ShoppingCart\ShoppingCartState;
|
|
|
|
echo "=== StateManager + LiveComponentState Integration Test ===\n\n";
|
|
|
|
// 1. Create StateManager for ShoppingCartState using factory method
|
|
$stateManager = InMemoryStateManager::for(ShoppingCartState::class);
|
|
|
|
echo "✅ Created InMemoryStateManager<ShoppingCartState>\n";
|
|
|
|
// 2. Create and store state
|
|
$cartState = ShoppingCartState::fromArray([
|
|
'items' => [
|
|
['id' => '1', 'name' => 'Product A', 'price' => 29.99, 'quantity' => 2],
|
|
['id' => '2', 'name' => 'Product B', 'price' => 15.50, 'quantity' => 1]
|
|
],
|
|
'discount_code' => 'SAVE10',
|
|
'discount_percentage' => 10
|
|
]);
|
|
|
|
$stateManager->setState('user-123', $cartState, Duration::fromHours(1));
|
|
echo "✅ Stored ShoppingCartState for user-123\n";
|
|
|
|
// 3. Retrieve state - TYPE PRESERVED!
|
|
$retrieved = $stateManager->getState('user-123');
|
|
|
|
echo "✅ Retrieved state type: " . get_class($retrieved) . "\n";
|
|
echo "✅ Discount code: " . $retrieved->discountCode . "\n";
|
|
echo "✅ Item count: " . count($retrieved->items) . "\n";
|
|
echo "✅ Discount percentage: " . $retrieved->discountPercentage . "%\n";
|
|
|
|
// 4. Verify type safety
|
|
if ($retrieved instanceof ShoppingCartState) {
|
|
echo "\n✅ TYPE SAFETY VERIFIED: Retrieved concrete ShoppingCartState (not mixed)!\n";
|
|
echo "✅ IDE auto-completion will work for: \$retrieved->items, \$retrieved->discountCode, etc.\n";
|
|
} else {
|
|
echo "\n❌ Type safety failed\n";
|
|
exit(1);
|
|
}
|
|
|
|
// 5. Test atomic update
|
|
echo "\n=== Testing Atomic State Update ===\n";
|
|
|
|
$updated = $stateManager->updateState(
|
|
'user-123',
|
|
function($state) {
|
|
return $state ? $state->withDiscountCode('SAVE20', 20) : ShoppingCartState::fromArray([]);
|
|
},
|
|
Duration::fromHours(1)
|
|
);
|
|
|
|
echo "✅ Updated discount code to: " . $updated->discountCode . " (" . $updated->discountPercentage . "%)\n";
|
|
|
|
// 6. Verify statistics
|
|
$stats = $stateManager->getStatistics();
|
|
echo "\n=== StateManager Statistics ===\n";
|
|
echo "Total keys: " . $stats->totalKeys . "\n";
|
|
echo "Hit count: " . $stats->hitCount . "\n";
|
|
echo "Miss count: " . $stats->missCount . "\n";
|
|
echo "Set count: " . $stats->setCount . "\n";
|
|
echo "Update count: " . $stats->updateCount . "\n";
|
|
|
|
echo "\n🎉 COMPLETE INTEGRATION SUCCESS!\n";
|
|
echo "✅ LiveComponentState works seamlessly with StateManager\n";
|
|
echo "✅ Type safety fully preserved throughout\n";
|
|
echo "✅ All domain-specific methods accessible\n";
|