[]]); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertInstanceOf(Addon::class, $addon); } public function testGetIdReturnsId(): void { $root = vfsStream::setup('addons', 0777, ['helloaddon' => []]); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertSame('helloaddon', $addon->getId()); } public function testGetRequiredDependenciesReturnsEmptyArray(): void { $root = vfsStream::setup('addons', 0777, ['helloaddon' => []]); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertSame( [], $addon->getRequiredDependencies() ); } public function testGetProvidedDependencyIncludesConfigFile(): void { $root = vfsStream::setup('addons_4', 0777, ['helloaddon' => ['static' => []]]); vfsStream::newFile('dependencies.config.php') ->at($root->getChild('helloaddon/static')) ->setContent(' []];'); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertSame( ['name' => []], $addon->getProvidedDependencyRules() ); } public function testGetSubscribedEventsReturnsEmptyArray(): void { $root = vfsStream::setup('addons', 0777, ['helloaddon' => []]); $addon = new LegacyAddonProxy('helloaddon', $root->url()); $this->assertSame( [], $addon->getSubscribedEvents() ); } public function testInitAddonIncludesAddonFile(): void { $root = vfsStream::setup('addons_1', 0777, ['helloaddon' => []]); vfsStream::newFile('helloaddon.php') ->at($root->getChild('helloaddon')) ->setContent('url()); try { $addon->initAddon([]); } catch (\Throwable $th) { $this->assertSame( 'Addon loaded', $th->getMessage() ); } } public function testInitAddonMultipleTimesWillIncludeFileOnlyOnce(): void { $root = vfsStream::setup('addons_2', 0777, ['helloaddon' => []]); vfsStream::newFile('helloaddon.php') ->at($root->getChild('helloaddon')) ->setContent('url()); try { $addon->initAddon([]); } catch (\Exception $th) { $this->assertSame( 'Addon loaded', $th->getMessage() ); } $addon->initAddon([]); $addon->initAddon([]); } public function testInstallAddonWillCallInstallFunction(): void { $root = vfsStream::setup('addons_3', 0777, ['helloaddon' => []]); vfsStream::newFile('helloaddon.php') ->at($root->getChild('helloaddon')) ->setContent('url()); $addon->initAddon([]); try { $addon->installAddon(); } catch (\Exception $th) { $this->assertSame( 'Addon installed', $th->getMessage() ); } } public function testUninstallAddonWillCallUninstallFunction(): void { $root = vfsStream::setup('addons_4', 0777, ['helloaddon' => []]); vfsStream::newFile('helloaddon.php') ->at($root->getChild('helloaddon')) ->setContent('url()); $addon->initAddon([]); try { $addon->uninstallAddon(); } catch (\Exception $th) { $this->assertSame( 'Addon uninstalled', $th->getMessage() ); } } }