load(new Registry()); $this->assertSame(['A', 'B', 'C'], $calls->getArrayCopy()); } public function testLastWriterWinsForConflictingKeys(): void { $registry = new Registry(); $first = new ToolWriterLoader('shared', static fn () => 'first'); $second = new ToolWriterLoader('shared', static fn () => 'second'); (new ChainLoader([$first, $second]))->load($registry); $this->assertSame('second', ($registry->getTool('shared')->handler)()); } public function testEmptyChainIsNoop(): void { $registry = new Registry(); (new ChainLoader([]))->load($registry); $this->assertFalse($registry->hasTools()); $this->assertFalse($registry->hasResources()); $this->assertFalse($registry->hasResourceTemplates()); $this->assertFalse($registry->hasPrompts()); } }