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); }