Skip to content

Commit

Permalink
✔️ Test added #49
Browse files Browse the repository at this point in the history
  • Loading branch information
Elie NEHME committed Dec 16, 2021
1 parent 5d92acd commit 524126e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $container = $factory(
// Enable compilation
Config::DI_CACHE_PATH => __DIR__, // Folder path

// Write proxy to file : cf. https://php-di.org/doc/lazy-injection.html
// Write proxies to file : cf. https://php-di.org/doc/lazy-injection.html
Config::DI_PROXY_PATH => __DIR__, // Folder path

// Disable autowire (enabled by default)
Expand Down
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(array $config)

public function configureContainer(ContainerBuilder $builder): void
{
$this->shouldWriteProxyToFile($builder);
$this->shouldWriteProxiesToFile($builder);

if (! $this->enableCompilation($builder)) {
$this->setDependencies();
Expand Down Expand Up @@ -164,7 +164,7 @@ private function enableCache(ContainerBuilder $builder): void
}
}

private function shouldWriteProxyToFile(ContainerBuilder $builder): void
private function shouldWriteProxiesToFile(ContainerBuilder $builder): void
{
$path = $this->definitions[self::CONFIG][self::DI_PROXY_PATH] ?? null;
if ($path) {
Expand Down
12 changes: 12 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public function testConfigurationEnableCompilation(): void
self::assertFalse($config[Config::ENABLE_CACHE_DEFINITION]);
}

public function testConfigurationWriteProxiesToFile(): void
{
$url = sys_get_temp_dir();
$config = [Config::DI_PROXY_PATH => $url];
$container = $this->getContainer($config);

$config = $container->get(Config::CONFIG);

self::assertNotEmpty($config);
self::assertSame($url, $config[Config::DI_PROXY_PATH]);
}

public function testConfigurationServices(): void
{
$config = [
Expand Down

0 comments on commit 524126e

Please sign in to comment.