container = new DefaultContainer(); $this->container->instance(MethodInvoker::class, new MethodInvoker( $this->container, new SimpleReflectionService() )); $this->discoveryRegistry = new DiscoveryRegistry( attributes: new AttributeRegistry() ); $callbackExecutor = new CallbackExecutor($this->container); $this->runner = new AttributeRunner( discoveryRegistry: $this->discoveryRegistry, container: $this->container, callbackExecutor: $callbackExecutor ); } public function testExecuteAttributesReturnsEmptyArrayWhenNoAttributes(): void { $results = $this->runner->executeAttributes(Guard::class); $this->assertIsArray($results); $this->assertEmpty($results); } public function testExecuteAttributeReturnsNullForNonExecutable(): void { $discovered = new DiscoveredAttribute( className: ClassName::create('TestClass'), attributeClass: 'NonExecutableAttribute', target: AttributeTarget::TARGET_CLASS ); $result = $this->runner->executeAttribute($discovered); $this->assertNull($result); } public function testExecuteForClass(): void { $className = ClassName::create('TestClass'); // Füge ein Guard-Attribut hinzu $discovered = new DiscoveredAttribute( className: $className, attributeClass: Guard::class, target: AttributeTarget::TARGET_CLASS, arguments: [\App\Framework\Attributes\Execution\Handlers\PermissionGuard::class, [['edit_post']]] ); $this->discoveryRegistry->attributes->add(Guard::class, $discovered); $results = $this->runner->executeForClass($className, Guard::class); $this->assertIsArray($results); } public function testExecuteForMethod(): void { $className = ClassName::create('TestClass'); $methodName = MethodName::create('testMethod'); // Füge ein Guard-Attribut hinzu $discovered = new DiscoveredAttribute( className: $className, attributeClass: Guard::class, target: AttributeTarget::METHOD, methodName: $methodName, arguments: [\App\Framework\Attributes\Execution\Handlers\PermissionGuard::class, [['edit_post']]] ); $this->discoveryRegistry->attributes->add(Guard::class, $discovered); $results = $this->runner->executeForMethod($className, $methodName, Guard::class); $this->assertIsArray($results); } }