Skip to content

Commit

Permalink
chore: setup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Dec 19, 2024
1 parent 254d568 commit b914263
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 5 additions & 15 deletions src/ServiceContainer/ServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,6 @@ public function __construct($configPath)
$this->configPath = $configPath;
}

/**
* @param string $configPath
*
* @return static
*/
public static function createInstance($configPath)
{
$container = new static($configPath);
$container->loadConfig();
$container->init();

return $container;
}

/**
* @return void
*/
Expand All @@ -91,10 +77,12 @@ public function loadConfig()
abstract public function getLogger();

/**
* @return void
* @return ServiceContainer
*/
public function init()
{
$this->loadConfig();

$this->getLogger()->debug('Initializing service container');

foreach ($this->provides as $provider) {
Expand All @@ -104,6 +92,8 @@ public function init()
(new $provider())->provide($this);
}
}

return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/src/ServiceContainer/ServiceContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ServiceContainerTest extends TestCase

public function setUp(): void
{
$this->container = TestServiceContainer::createInstance(__DIR__ . '/config.php');
$this->container = (new TestServiceContainer(__DIR__ . '/config.php'))->init();
}

/**
Expand Down

0 comments on commit b914263

Please sign in to comment.