shouldReceive('getId') ->andReturn(ComponentId::create('counter', 'demo')); $mockComponent->shouldReceive('getData') ->andReturn(ComponentData::fromArray(['initialValue' => 5])); $mockComponent->shouldReceive('getRenderData') ->andReturn(new ComponentRenderData('counter-template', ['value' => 5])); // Mock LiveComponent Registry $liveComponentRegistry = Mockery::mock(ComponentRegistryInterface::class); $liveComponentRegistry->shouldReceive('isRegistered') ->with('counter') ->andReturn(true); $liveComponentRegistry->shouldReceive('getClassName') ->with('counter') ->andReturn('TestCounterComponent'); $liveComponentRegistry->shouldReceive('resolve') ->andReturn($mockComponent); $liveComponentRegistry->shouldReceive('renderWithWrapper') ->with($mockComponent) ->andReturn('
Counter HTML
'); $liveComponentRegistry->shouldReceive('getAllComponentNames') ->andReturn(['counter']); // Mock HTML Component Registry $htmlComponentRegistry = Mockery::mock(HtmlComponentRegistryInterface::class); $htmlComponentRegistry->shouldReceive('has') ->andReturn(false); $htmlComponentRegistry->shouldReceive('getAllComponentNames') ->andReturn([]); // Mock Metadata Cache $mockMetadata = new CompiledComponentMetadata( className: 'TestCounterComponent', componentName: 'counter', properties: [ 'initialValue' => new ComponentPropertyMetadata( name: 'initialValue', type: 'int', isPublic: true, isReadonly: false ) ], actions: [], constructorParams: [] ); $metadataCache = Mockery::mock(ComponentMetadataCacheInterface::class); $metadataCache->shouldReceive('get') ->with('TestCounterComponent') ->andReturn($mockMetadata); // Create transformer instance $parser = new HtmlParser(); $xComponentTransformer = new XComponentTransformer( $liveComponentRegistry, $htmlComponentRegistry, $metadataCache, $parser ); // Create AST Pipeline with transformer instance $pipeline = new AstProcessingPipeline( transformers: [$xComponentTransformer], parser: $parser ); // Test HTML $html = '

Test

Done

'; echo "Input HTML:\n$html\n\n"; // Create RenderContext $context = new RenderContext( template: 'test-pipeline', metaData: new MetaData('Pipeline Test'), data: [] ); // Process through pipeline $document = $pipeline->process($context, $html); echo "Pipeline processing completed ✓\n\n"; // Render to HTML $renderer = new HtmlRenderer(); $output = $renderer->render($document); echo "Output HTML:\n$output\n\n"; // Verify if (str_contains($output, 'data-component-id="counter:demo"')) { echo "✓ SUCCESS: Component processed through pipeline!\n"; } else { echo "✗ FAIL: Component not found in output\n"; } if (str_contains($output, '

Test

')) { echo "✓ SUCCESS: Content preserved!\n"; } else { echo "✗ FAIL: Content lost\n"; }