- 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.
119 lines
3.8 KiB
PHP
119 lines
3.8 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\LiveComponents\Contracts\ComponentRegistryInterface;
|
|
use App\Framework\LiveComponents\Contracts\LiveComponentContract;
|
|
use App\Framework\LiveComponents\Performance\CompiledComponentMetadata;
|
|
use App\Framework\LiveComponents\Performance\ComponentMetadataCacheInterface;
|
|
use App\Framework\LiveComponents\Performance\ComponentPropertyMetadata;
|
|
use App\Framework\LiveComponents\ValueObjects\ComponentData;
|
|
use App\Framework\LiveComponents\ValueObjects\ComponentId;
|
|
use App\Framework\LiveComponents\ValueObjects\ComponentRenderData;
|
|
use App\Framework\Meta\MetaData;
|
|
use App\Framework\Template\Parser\DomTemplateParser;
|
|
use App\Framework\View\Contracts\HtmlComponentRegistryInterface;
|
|
use App\Framework\View\DomComponentService;
|
|
use App\Framework\View\Processors\XComponentProcessor;
|
|
use App\Framework\View\RenderContext;
|
|
|
|
// Mock dependencies
|
|
$liveComponentRegistry = Mockery::mock(ComponentRegistryInterface::class);
|
|
$htmlComponentRegistry = Mockery::mock(HtmlComponentRegistryInterface::class);
|
|
$metadataCache = Mockery::mock(ComponentMetadataCacheInterface::class);
|
|
$componentService = new DomComponentService();
|
|
|
|
$processor = new XComponentProcessor(
|
|
$liveComponentRegistry,
|
|
$htmlComponentRegistry,
|
|
$metadataCache,
|
|
$componentService
|
|
);
|
|
|
|
$parser = new DomTemplateParser();
|
|
|
|
// Test HTML
|
|
$html = '<html><body><x-counter id="demo" initialValue="5" /></body></html>';
|
|
echo "Input HTML: $html\n\n";
|
|
|
|
$dom = $parser->parseToWrapper($html);
|
|
echo "Parsed HTML: " . $dom->document->saveHTML() . "\n\n";
|
|
|
|
// Check body content
|
|
$body = $dom->document->getElementsByTagName('body')[0];
|
|
echo "Body children: " . $body->childNodes->length . "\n";
|
|
foreach ($body->childNodes as $child) {
|
|
echo " - " . $child->nodeName . " (" . get_class($child) . ")\n";
|
|
}
|
|
echo "\n";
|
|
|
|
// Mock LiveComponent
|
|
$mockComponent = Mockery::mock(LiveComponentContract::class);
|
|
$mockComponent->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]));
|
|
|
|
// Setup registry mocks
|
|
$liveComponentRegistry->shouldReceive('isRegistered')
|
|
->with('counter')
|
|
->andReturn(true);
|
|
|
|
$liveComponentRegistry->shouldReceive('getClassName')
|
|
->with('counter')
|
|
->andReturn('TestCounterComponent');
|
|
|
|
$liveComponentRegistry->shouldReceive('resolve')
|
|
->once()
|
|
->andReturn($mockComponent);
|
|
|
|
$liveComponentRegistry->shouldReceive('renderWithWrapper')
|
|
->with($mockComponent)
|
|
->andReturn('<div data-component-id="counter:demo">Counter HTML</div>');
|
|
|
|
// Mock metadata
|
|
$mockMetadata = new CompiledComponentMetadata(
|
|
className: 'TestCounterComponent',
|
|
componentName: 'counter',
|
|
properties: [
|
|
'initialValue' => new ComponentPropertyMetadata(
|
|
name: 'initialValue',
|
|
type: 'int',
|
|
isPublic: true,
|
|
isReadonly: false
|
|
)
|
|
],
|
|
actions: [],
|
|
constructorParams: []
|
|
);
|
|
$metadataCache->shouldReceive('get')
|
|
->with('TestCounterComponent')
|
|
->andReturn($mockMetadata);
|
|
|
|
// Process
|
|
echo "Processing...\n";
|
|
$context = new RenderContext(
|
|
template: 'test-template',
|
|
metaData: new MetaData('Test Component Processing'),
|
|
data: []
|
|
);
|
|
|
|
try {
|
|
$result = $processor->process($dom, $context);
|
|
echo "Processing successful!\n\n";
|
|
|
|
$html = $result->document->saveHTML();
|
|
echo "Result HTML: $html\n\n";
|
|
|
|
if (str_contains($html, 'data-component-id="counter:demo"')) {
|
|
echo "✓ SUCCESS: Contains expected content!\n";
|
|
} else {
|
|
echo "✗ FAIL: Does not contain expected content\n";
|
|
}
|
|
} catch (\Throwable $e) {
|
|
echo "ERROR: " . $e->getMessage() . "\n";
|
|
echo $e->getTraceAsString() . "\n";
|
|
}
|