mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-10 23:14:27 +02:00
Let Addon class provide dependencies into addon
This commit is contained in:
parent
b3bc5981ea
commit
f2a26fde4e
3 changed files with 33 additions and 3 deletions
|
@ -13,6 +13,7 @@ use Friendica\Addon\Addon;
|
|||
use Friendica\Addon\AddonBootstrap;
|
||||
use Friendica\Addon\Event\AddonStartEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AddonTest extends TestCase
|
||||
{
|
||||
|
@ -35,4 +36,23 @@ class AddonTest extends TestCase
|
|||
$addon = new Addon($bootstrap);
|
||||
$addon->initAddon();
|
||||
}
|
||||
|
||||
public function testInitAddonCallsBootstrapWithDependencies(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(AddonBootstrap::class);
|
||||
|
||||
$bootstrap->expects($this->once())->method('initAddon')->willReturnCallback(function(AddonStartEvent $event) {
|
||||
$dependencies = $event->getDependencies();
|
||||
|
||||
$this->assertArrayHasKey(LoggerInterface::class, $dependencies);
|
||||
$this->assertInstanceOf(LoggerInterface::class, $dependencies[LoggerInterface::class]);
|
||||
});
|
||||
|
||||
$addon = new Addon(
|
||||
$bootstrap,
|
||||
[LoggerInterface::class => $this->createMock(LoggerInterface::class)]
|
||||
);
|
||||
|
||||
$addon->initAddon();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue