mirror of
https://github.com/friendica/friendica
synced 2025-04-27 19:50:12 +00:00
Add UnitTest for Container
This commit is contained in:
parent
2238ea8d52
commit
560bf345da
4 changed files with 53 additions and 1 deletions
|
@ -5,6 +5,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Dice\Dice;
|
||||
|
|
|
@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class AppTest extends TestCase
|
||||
{
|
||||
public function testFromDiceReturnsApp(): void
|
||||
public function testFromContainerReturnsApp(): void
|
||||
{
|
||||
$container = $this->createMock(Container::class);
|
||||
$container->expects($this->never())->method('create');
|
||||
|
|
48
tests/Unit/Core/ContainerTest.php
Normal file
48
tests/Unit/Core/ContainerTest.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?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 Core;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\Core\Container;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
class ContainerTest extends TestCase
|
||||
{
|
||||
public function testFromDiceReturnsContainer(): void
|
||||
{
|
||||
$dice = $this->createMock(Dice::class);
|
||||
$dice->expects($this->never())->method('create');
|
||||
|
||||
$container = Container::fromDice($dice);
|
||||
|
||||
$this->assertInstanceOf(Container::class, $container);
|
||||
}
|
||||
|
||||
public function testCreateFromContainer(): void
|
||||
{
|
||||
$dice = $this->createMock(Dice::class);
|
||||
$dice->expects($this->once())->method('create')->with(LoggerInterface::class)->willReturn(new NullLogger());
|
||||
|
||||
$container = Container::fromDice($dice);
|
||||
|
||||
$this->assertInstanceOf(NullLogger::class, $container->create(LoggerInterface::class));
|
||||
}
|
||||
|
||||
public function testAddRuleFromContainer(): void
|
||||
{
|
||||
$dice = $this->createMock(Dice::class);
|
||||
$dice->expects($this->once())->method('addRule')->with(LoggerInterface::class, ['constructParams' => ['console']])->willReturn($dice);
|
||||
|
||||
$container = Container::fromDice($dice);
|
||||
$container->addRule(LoggerInterface::class, ['constructParams' => ['console']]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue