Add Addon::getId() method

This commit is contained in:
Art4 2025-01-08 12:52:21 +00:00
parent 66fb982124
commit 1f25fe9bf5
8 changed files with 89 additions and 25 deletions

View file

@ -29,11 +29,11 @@ class AddonManagerTest extends TestCase
public function testGetAllSubscribedEventsReturnsEvents(): void
{
$addon = $this->createMock(Addon::class);
$addon->expects($this->once())->method('getSubscribedEvents')->willReturn([[HtmlFilterEvent::PAGE_END, [Addon::class, 'onPageEnd']]]);
$addon = $this->createStub(Addon::class);
$addon->method('getSubscribedEvents')->willReturn([[HtmlFilterEvent::PAGE_END, [Addon::class, 'onPageEnd']]]);
$loader = $this->createMock(AddonLoader::class);
$loader->expects($this->once())->method('getAddons')->willReturn(['helloaddon' => $addon]);
$loader = $this->createStub(AddonLoader::class);
$loader->method('getAddons')->willReturn(['helloaddon' => $addon]);
$manager = new AddonManager($loader);
@ -44,4 +44,23 @@ class AddonManagerTest extends TestCase
$manager->getAllSubscribedEvents()
);
}
public function testGetRequiredDependenciesReturnsArray(): void
{
$addon = $this->createStub(Addon::class);
$addon->method('getId')->willReturn('helloaddon');
$addon->method('getRequiredDependencies')->willReturn(['foo', 'bar']);
$loader = $this->createStub(AddonLoader::class);
$loader->method('getAddons')->willReturn(['helloaddon' => $addon]);
$manager = new AddonManager($loader);
$manager->bootstrapAddons(['helloaddon' => []]);
$this->assertSame(
['helloaddon' => ['foo', 'bar']],
$manager->getRequiredDependencies()
);
}
}