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,143 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Framework\Discovery\Results;
|
||||
|
||||
use App\Framework\Discovery\Results\AttributeRegistry;
|
||||
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
||||
use App\Framework\Discovery\Results\InterfaceRegistry;
|
||||
use App\Framework\Discovery\Results\TemplateRegistry;
|
||||
use App\Framework\Attributes\Route;
|
||||
use App\Framework\Console\ConsoleCommand;
|
||||
use App\Framework\DI\Initializer;
|
||||
use App\Framework\Core\ValueObjects\ClassName;
|
||||
use App\Framework\Core\ValueObjects\MethodName;
|
||||
use App\Framework\Discovery\ValueObjects\AttributeTarget;
|
||||
use App\Framework\Discovery\ValueObjects\DiscoveredAttribute;
|
||||
use App\Framework\Http\Method;
|
||||
|
||||
describe('DiscoveryRegistry Validation Methods', function () {
|
||||
it('hasRoutes returns true when routes are present', function () {
|
||||
$attributes = new AttributeRegistry();
|
||||
$routeAttribute = new DiscoveredAttribute(
|
||||
className: ClassName::create('App\\Test\\Controller'),
|
||||
attributeClass: Route::class,
|
||||
target: AttributeTarget::METHOD,
|
||||
methodName: MethodName::create('index'),
|
||||
arguments: ['path' => '/test', 'method' => Method::GET],
|
||||
additionalData: []
|
||||
);
|
||||
$attributes->add(Route::class, $routeAttribute);
|
||||
|
||||
$registry = new DiscoveryRegistry(
|
||||
attributes: $attributes,
|
||||
interfaces: new InterfaceRegistry(),
|
||||
templates: new TemplateRegistry()
|
||||
);
|
||||
|
||||
expect($registry->hasRoutes())->toBeTrue();
|
||||
expect($registry->hasCommands())->toBeFalse();
|
||||
expect($registry->hasInitializers())->toBeFalse();
|
||||
expect($registry->hasContent())->toBeTrue();
|
||||
});
|
||||
|
||||
it('hasCommands returns true when commands are present', function () {
|
||||
$attributes = new AttributeRegistry();
|
||||
$commandAttribute = new DiscoveredAttribute(
|
||||
className: ClassName::create('App\\Test\\Command'),
|
||||
attributeClass: ConsoleCommand::class,
|
||||
target: AttributeTarget::METHOD,
|
||||
methodName: MethodName::create('handle'),
|
||||
arguments: ['name' => 'test:command'],
|
||||
additionalData: []
|
||||
);
|
||||
$attributes->add(ConsoleCommand::class, $commandAttribute);
|
||||
|
||||
$registry = new DiscoveryRegistry(
|
||||
attributes: $attributes,
|
||||
interfaces: new InterfaceRegistry(),
|
||||
templates: new TemplateRegistry()
|
||||
);
|
||||
|
||||
expect($registry->hasRoutes())->toBeFalse();
|
||||
expect($registry->hasCommands())->toBeTrue();
|
||||
expect($registry->hasInitializers())->toBeFalse();
|
||||
expect($registry->hasContent())->toBeTrue();
|
||||
});
|
||||
|
||||
it('hasInitializers returns true when initializers are present', function () {
|
||||
$attributes = new AttributeRegistry();
|
||||
$initializerAttribute = new DiscoveredAttribute(
|
||||
className: ClassName::create('App\\Test\\Initializer'),
|
||||
attributeClass: Initializer::class,
|
||||
target: AttributeTarget::METHOD,
|
||||
methodName: MethodName::create('initialize'),
|
||||
arguments: [],
|
||||
additionalData: []
|
||||
);
|
||||
$attributes->add(Initializer::class, $initializerAttribute);
|
||||
|
||||
$registry = new DiscoveryRegistry(
|
||||
attributes: $attributes,
|
||||
interfaces: new InterfaceRegistry(),
|
||||
templates: new TemplateRegistry()
|
||||
);
|
||||
|
||||
expect($registry->hasRoutes())->toBeFalse();
|
||||
expect($registry->hasCommands())->toBeFalse();
|
||||
expect($registry->hasInitializers())->toBeTrue();
|
||||
expect($registry->hasContent())->toBeTrue();
|
||||
});
|
||||
|
||||
it('hasContent returns false when registry is empty', function () {
|
||||
$registry = DiscoveryRegistry::empty();
|
||||
|
||||
expect($registry->hasRoutes())->toBeFalse();
|
||||
expect($registry->hasCommands())->toBeFalse();
|
||||
expect($registry->hasInitializers())->toBeFalse();
|
||||
expect($registry->hasContent())->toBeFalse();
|
||||
});
|
||||
|
||||
it('getContentSummary returns correct counts', function () {
|
||||
$attributes = new AttributeRegistry();
|
||||
|
||||
// Add route
|
||||
$routeAttribute = new DiscoveredAttribute(
|
||||
className: ClassName::create('App\\Test\\Controller'),
|
||||
attributeClass: Route::class,
|
||||
target: AttributeTarget::METHOD,
|
||||
methodName: MethodName::create('index'),
|
||||
arguments: ['path' => '/test', 'method' => Method::GET],
|
||||
additionalData: []
|
||||
);
|
||||
$attributes->add(Route::class, $routeAttribute);
|
||||
|
||||
// Add command
|
||||
$commandAttribute = new DiscoveredAttribute(
|
||||
className: ClassName::create('App\\Test\\Command'),
|
||||
attributeClass: ConsoleCommand::class,
|
||||
target: AttributeTarget::METHOD,
|
||||
methodName: MethodName::create('handle'),
|
||||
arguments: ['name' => 'test:command'],
|
||||
additionalData: []
|
||||
);
|
||||
$attributes->add(ConsoleCommand::class, $commandAttribute);
|
||||
|
||||
$registry = new DiscoveryRegistry(
|
||||
attributes: $attributes,
|
||||
interfaces: new InterfaceRegistry(),
|
||||
templates: new TemplateRegistry()
|
||||
);
|
||||
|
||||
$summary = $registry->getContentSummary();
|
||||
|
||||
expect($summary)->toBeArray();
|
||||
expect($summary['routes'])->toBe(1);
|
||||
expect($summary['commands'])->toBe(1);
|
||||
expect($summary['initializers'])->toBe(0);
|
||||
expect($summary['interfaces'])->toBe(0);
|
||||
expect($summary['templates'])->toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user