fix: DockerSecretsResolver - don't normalize absolute paths like /var/www/html/...
Some checks failed
Deploy Application / deploy (push) Has been cancelled
Some checks failed
Deploy Application / deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Framework\LiveComponents\Performance;
|
||||
|
||||
use App\Application\LiveComponents\Counter\CounterComponent;
|
||||
use App\Framework\LiveComponents\Attributes\Island;
|
||||
use App\Framework\LiveComponents\Attributes\LiveComponent;
|
||||
use App\Framework\LiveComponents\Contracts\LiveComponentContract;
|
||||
use App\Framework\LiveComponents\Performance\ComponentMetadataCompiler;
|
||||
use App\Framework\LiveComponents\Performance\CompiledComponentMetadata;
|
||||
use App\Framework\LiveComponents\ValueObjects\ComponentId;
|
||||
use App\Framework\LiveComponents\ValueObjects\ComponentState;
|
||||
|
||||
describe('Island Metadata Detection', function () {
|
||||
it('detects Island attribute in component', function () {
|
||||
$compiler = new ComponentMetadataCompiler();
|
||||
|
||||
// Create a test component with Island attribute
|
||||
$componentClass = IslandTestComponent::class;
|
||||
$metadata = $compiler->compile($componentClass);
|
||||
|
||||
expect($metadata->isIsland())->toBeTrue();
|
||||
expect($metadata->getIsland())->not->toBeNull();
|
||||
|
||||
$island = $metadata->getIsland();
|
||||
expect($island['isolated'])->toBeTrue();
|
||||
expect($island['lazy'])->toBeFalse();
|
||||
expect($island['placeholder'])->toBeNull();
|
||||
});
|
||||
|
||||
it('detects Island attribute with lazy loading', function () {
|
||||
$compiler = new ComponentMetadataCompiler();
|
||||
|
||||
$componentClass = LazyIslandTestComponent::class;
|
||||
$metadata = $compiler->compile($componentClass);
|
||||
|
||||
expect($metadata->isIsland())->toBeTrue();
|
||||
|
||||
$island = $metadata->getIsland();
|
||||
expect($island['isolated'])->toBeTrue();
|
||||
expect($island['lazy'])->toBeTrue();
|
||||
expect($island['placeholder'])->toBe('Loading component...');
|
||||
});
|
||||
|
||||
it('returns null for non-island components', function () {
|
||||
$compiler = new ComponentMetadataCompiler();
|
||||
|
||||
$metadata = $compiler->compile(CounterComponent::class);
|
||||
|
||||
expect($metadata->isIsland())->toBeFalse();
|
||||
expect($metadata->getIsland())->toBeNull();
|
||||
});
|
||||
|
||||
it('serializes Island metadata in toArray', function () {
|
||||
$compiler = new ComponentMetadataCompiler();
|
||||
|
||||
$metadata = $compiler->compile(IslandTestComponent::class);
|
||||
$array = $metadata->toArray();
|
||||
|
||||
expect($array)->toHaveKey('island');
|
||||
expect($array['island'])->not->toBeNull();
|
||||
expect($array['island']['isolated'])->toBeTrue();
|
||||
expect($array['island']['lazy'])->toBeFalse();
|
||||
});
|
||||
|
||||
it('deserializes Island metadata from array', function () {
|
||||
$compiler = new ComponentMetadataCompiler();
|
||||
|
||||
$metadata = $compiler->compile(IslandTestComponent::class);
|
||||
$array = $metadata->toArray();
|
||||
|
||||
$restored = CompiledComponentMetadata::fromArray($array);
|
||||
|
||||
expect($restored->isIsland())->toBeTrue();
|
||||
expect($restored->getIsland())->not->toBeNull();
|
||||
|
||||
$island = $restored->getIsland();
|
||||
expect($island['isolated'])->toBeTrue();
|
||||
expect($island['lazy'])->toBeFalse();
|
||||
});
|
||||
});
|
||||
|
||||
// Test component classes
|
||||
#[LiveComponent('island-test')]
|
||||
#[Island]
|
||||
final readonly class IslandTestComponent implements LiveComponentContract
|
||||
{
|
||||
public function __construct(
|
||||
public ComponentId $id,
|
||||
public ComponentState $state
|
||||
) {
|
||||
}
|
||||
|
||||
public function getRenderData(): \App\Framework\LiveComponents\ValueObjects\ComponentRenderData
|
||||
{
|
||||
return new \App\Framework\LiveComponents\ValueObjects\ComponentRenderData(
|
||||
templatePath: 'test',
|
||||
data: []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[LiveComponent('lazy-island-test')]
|
||||
#[Island(isolated: true, lazy: true, placeholder: 'Loading component...')]
|
||||
final readonly class LazyIslandTestComponent implements LiveComponentContract
|
||||
{
|
||||
public function __construct(
|
||||
public ComponentId $id,
|
||||
public ComponentState $state
|
||||
) {
|
||||
}
|
||||
|
||||
public function getRenderData(): \App\Framework\LiveComponents\ValueObjects\ComponentRenderData
|
||||
{
|
||||
return new \App\Framework\LiveComponents\ValueObjects\ComponentRenderData(
|
||||
templatePath: 'test',
|
||||
data: []
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user