From 316fac0161b4d02a094fa523c2176fb4b843f0aa Mon Sep 17 00:00:00 2001 From: Art4 Date: Wed, 8 Jan 2025 22:52:30 +0000 Subject: [PATCH] Add tests for Container::fromBasePath() --- tests/Unit/Core/ContainerTest.php | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Unit/Core/ContainerTest.php b/tests/Unit/Core/ContainerTest.php index bb5ccda398..5c56c696be 100644 --- a/tests/Unit/Core/ContainerTest.php +++ b/tests/Unit/Core/ContainerTest.php @@ -11,12 +11,45 @@ namespace Core; use Dice\Dice; use Friendica\Core\Container; +use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; class ContainerTest extends TestCase { + public function testFromBasePathReturnsContainer(): void + { + $root = vfsStream::setup('friendica', null, [ + 'static' => [ + 'dependencies.config.php' => 'url()); + + $this->assertInstanceOf(Container::class, $container); + } + + public function testCreateReturnsObject(): void + { + $root = vfsStream::setup('friendica', null, [ + 'static' => [ + 'dependencies.config.php' => <<< PHP + [ + 'instanceOf' => \Psr\Log\NullLogger::class, + ], + ]; + PHP, + ], + ]); + + $container = Container::fromBasePath($root->url()); + + $this->assertInstanceOf(NullLogger::class, $container->create(LoggerInterface::class)); + } + public function testFromDiceReturnsContainer(): void { $dice = $this->createMock(Dice::class); -- 2.39.5