Files
michaelschiemer/tests/debug/test-dataprovider-simple.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

144 lines
4.7 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Application\LiveComponents\InfiniteScroll\InfiniteScrollComponent;
use App\Application\LiveComponents\Services\DemoScrollDataProvider;
use App\Framework\DI\DefaultContainer;
use App\Framework\Discovery\UnifiedDiscoveryService;
use App\Framework\LiveComponents\DataProviderResolver;
use App\Framework\LiveComponents\ValueObjects\ComponentId;
echo "\nTesting DataProvider Resolution Flow\n";
echo str_repeat('=', 70) . "\n\n";
// 1. Setup minimal dependencies
echo "1. Setting up DataProviderResolver...\n";
$container = new DefaultContainer();
// Bootstrap discovery system
$basePath = dirname(__DIR__, 2) . '/src';
$cacheDir = dirname(__DIR__, 2) . '/storage/cache';
$discovery = UnifiedDiscoveryService::createForWeb($basePath, $cacheDir);
// Register discovery
$container->singleton(UnifiedDiscoveryService::class, $discovery);
// Register DemoScrollDataProvider
$container->singleton(DemoScrollDataProvider::class, fn () => new DemoScrollDataProvider());
// Create DataProviderResolver
$resolver = new DataProviderResolver($discovery);
echo "✓ DataProviderResolver created\n\n";
// 2. Test 1: Initial Render with dataSource
echo "2. Test 1: Initial Render 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";
$initialData = $component->getData();
echo " - dataSource in state: " . $initialData->get('data_source') . "\n";
echo " - Initial items: " . count($initialData->get('items')) . "\n\n";
// 3. Test 2: Execute Action
echo "3. Test 2: Execute Action - loadMore()...\n";
try {
$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";
} catch (Exception $e) {
echo "✗ ERROR in loadMore(): " . $e->getMessage() . "\n";
echo " Stack trace:\n";
echo $e->getTraceAsString() . "\n\n";
exit(1);
}
// 4. Test 3: State Restoration
echo "4. Test 3: State Restoration from ComponentData...\n";
try {
$restoredComponent = new InfiniteScrollComponent(
id: ComponentId::fromString('scroll:test'),
dataProviderResolver: $resolver,
initialData: $actionResult
);
echo "✓ Component restored from state\n";
$restoredData = $restoredComponent->getData();
echo " - Restored items: " . count($restoredData->get('items')) . "\n";
echo " - Restored page: " . $restoredData->get('current_page') . "\n";
echo " - Restored dataSource: " . $restoredData->get('data_source') . "\n\n";
} catch (Exception $e) {
echo "✗ ERROR in state restoration: " . $e->getMessage() . "\n";
echo " Stack trace:\n";
echo $e->getTraceAsString() . "\n\n";
exit(1);
}
// 5. Test 4: Action on Restored Component
echo "5. Test 4: Action on Restored Component - loadMore()...\n";
try {
$secondActionResult = $restoredComponent->loadMore();
echo "✓ Second action executed\n";
$secondItems = $secondActionResult->get('items');
echo " - Total items: " . count($secondItems) . "\n";
echo " - Current page: " . $secondActionResult->get('current_page') . "\n";
echo " - dataSource: " . $secondActionResult->get('data_source') . "\n\n";
} catch (Exception $e) {
echo "✗ ERROR in second loadMore(): " . $e->getMessage() . "\n";
echo " Stack trace:\n";
echo $e->getTraceAsString() . "\n\n";
exit(1);
}
// 6. Verify Results
echo "6. Verifying Results...\n";
$allPassed = true;
if ($secondActionResult->get('data_source') !== 'demo') {
echo "✗ FAIL: dataSource not preserved (expected 'demo', got '" . $secondActionResult->get('data_source') . "')\n";
$allPassed = false;
} else {
echo "✓ PASS: dataSource preserved correctly\n";
}
if ($secondActionResult->get('current_page') !== 2) {
echo "✗ FAIL: Page count incorrect (expected 2, got " . $secondActionResult->get('current_page') . ")\n";
$allPassed = false;
} else {
echo "✓ PASS: Page count correct (2)\n";
}
if (count($secondItems) !== 10) {
echo "✗ FAIL: Item count incorrect (expected 10, got " . count($secondItems) . ")\n";
$allPassed = false;
} else {
echo "✓ PASS: Item count correct (10)\n";
}
echo "\n" . str_repeat('=', 70) . "\n";
if ($allPassed) {
echo "✓✓✓ ALL TESTS PASSED ✓✓✓\n";
echo "DataProvider resolution flow works correctly!\n";
exit(0);
} else {
echo "✗✗✗ SOME TESTS FAILED ✗✗✗\n";
exit(1);
}