]> git.mxchange.org Git - friendica.git/commitdiff
Add tests for Container::fromBasePath()
authorArt4 <art4@wlabs.de>
Wed, 8 Jan 2025 22:52:30 +0000 (22:52 +0000)
committerArt4 <art4@wlabs.de>
Wed, 8 Jan 2025 22:52:30 +0000 (22:52 +0000)
tests/Unit/Core/ContainerTest.php

index bb5ccda398734b4ea60baf3676a5d5ec525dffeb..5c56c696be0b541211777b1ebebb16a372e5d0f1 100644 (file)
@@ -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' => '<?php return [];',
+                       ],
+               ]);
+
+               $container = Container::fromBasePath($root->url());
+
+               $this->assertInstanceOf(Container::class, $container);
+       }
+
+       public function testCreateReturnsObject(): void
+       {
+               $root = vfsStream::setup('friendica', null, [
+                       'static' => [
+                               'dependencies.config.php' => <<< PHP
+                                       <?php return [
+                                               \Psr\Log\LoggerInterface::class => [
+                                                       '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);