mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-12 03:24:26 +02:00
Rename Addon class to AddonProxy, create Addon interface
This commit is contained in:
parent
92505dca7b
commit
73a55e4700
4 changed files with 59 additions and 35 deletions
59
tests/Unit/Service/Addon/AddonProxyTest.php
Normal file
59
tests/Unit/Service/Addon/AddonProxyTest.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Addon;
|
||||
|
||||
use Friendica\Addon\AddonBootstrap;
|
||||
use Friendica\Addon\Event\AddonStartEvent;
|
||||
use Friendica\Service\Addon\Addon;
|
||||
use Friendica\Service\Addon\AddonProxy;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AddonProxyTest extends TestCase
|
||||
{
|
||||
public function testCreateWithAddonBootstrap(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(AddonBootstrap::class);
|
||||
|
||||
$addon = new AddonProxy($bootstrap);
|
||||
|
||||
$this->assertInstanceOf(Addon::class, $addon);
|
||||
}
|
||||
|
||||
public function testInitAddonCallsBootstrap(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(AddonBootstrap::class);
|
||||
$bootstrap->expects($this->once())->method('initAddon')->willReturnCallback(function($event) {
|
||||
$this->assertInstanceOf(AddonStartEvent::class, $event);
|
||||
});
|
||||
|
||||
$addon = new AddonProxy($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 AddonProxy($bootstrap);
|
||||
|
||||
$addon->initAddon(
|
||||
[LoggerInterface::class => $this->createMock(LoggerInterface::class)]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue