diff --git a/src/Console/AbstractConsole.php b/src/Console/AbstractConsole.php index 9c4a53bdaf..bce4a46268 100644 --- a/src/Console/AbstractConsole.php +++ b/src/Console/AbstractConsole.php @@ -5,6 +5,8 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +declare(strict_types = 1); + namespace Friendica\Console; use Asika\SimpleConsole\Console; diff --git a/src/Core/Container.php b/src/Core/Container.php index 64a05150c0..c77a2a127e 100644 --- a/src/Core/Container.php +++ b/src/Core/Container.php @@ -5,6 +5,8 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +declare(strict_types = 1); + namespace Friendica\Core; use Dice\Dice; diff --git a/tests/Unit/AppTest.php b/tests/Unit/AppTest.php index 937e2a867a..1854c993e4 100644 --- a/tests/Unit/AppTest.php +++ b/tests/Unit/AppTest.php @@ -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'); diff --git a/tests/Unit/Core/ContainerTest.php b/tests/Unit/Core/ContainerTest.php new file mode 100644 index 0000000000..6111a72bb0 --- /dev/null +++ b/tests/Unit/Core/ContainerTest.php @@ -0,0 +1,48 @@ +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']]); + } +}