mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-11 02:14:31 +02:00
Switch back to dynamic getter methods because static methods cannot been mocked in tests
This commit is contained in:
parent
73a55e4700
commit
82470738e4
6 changed files with 39 additions and 11 deletions
|
@ -10,12 +10,18 @@ declare(strict_types=1);
|
|||
namespace Friendica\Test\Unit\Addon;
|
||||
|
||||
use Friendica\Addon\AddonBootstrap;
|
||||
use Friendica\Addon\DependencyProvider;
|
||||
use Friendica\Addon\Event\AddonStartEvent;
|
||||
use Friendica\Service\Addon\Addon;
|
||||
use Friendica\Service\Addon\AddonProxy;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Helper interface to combine AddonBootstrap and DependencyProvider.
|
||||
*/
|
||||
interface CombinedAddonBootstrapDependencyProvider extends AddonBootstrap, DependencyProvider {}
|
||||
|
||||
class AddonProxyTest extends TestCase
|
||||
{
|
||||
public function testCreateWithAddonBootstrap(): void
|
||||
|
@ -27,6 +33,26 @@ class AddonProxyTest extends TestCase
|
|||
$this->assertInstanceOf(Addon::class, $addon);
|
||||
}
|
||||
|
||||
public function testGetRequiredDependenciesCallsBootstrap(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(AddonBootstrap::class);
|
||||
$bootstrap->expects($this->once())->method('getRequiredDependencies')->willReturn([]);
|
||||
|
||||
$addon = new AddonProxy($bootstrap);
|
||||
|
||||
$addon->getRequiredDependencies();
|
||||
}
|
||||
|
||||
public function testGetProvidedDependencyRulesCallsBootstrap(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(CombinedAddonBootstrapDependencyProvider::class);
|
||||
$bootstrap->expects($this->once())->method('provideDependencyRules')->willReturn([]);
|
||||
|
||||
$addon = new AddonProxy($bootstrap);
|
||||
|
||||
$addon->getProvidedDependencyRules();
|
||||
}
|
||||
|
||||
public function testInitAddonCallsBootstrap(): void
|
||||
{
|
||||
$bootstrap = $this->createMock(AddonBootstrap::class);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue