Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve containers types to use iterable objects #299

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
xepozz committed Dec 2, 2022
commit f2832b76ee3f2de051c4fd61aac61c4e1155cad9
21 changes: 21 additions & 0 deletions tests/Unit/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1996,4 +1996,25 @@ public function testInvalidTags(string $message, array $tags): void
$this->expectExceptionMessage($message);
new Container($config);
}

public function testSupportIterableDefinitions(): void
{
$config = ContainerConfig::create()
->withDefinitions(
(function () {
yield from [
EngineMarkOne::class => [
'class' => EngineMarkOne::class,
'setNumber()' => [42],
],
];
})()
);

$container = new Container($config);

$this->assertTrue($container->has(EngineMarkOne::class));
$engine = $container->get(EngineMarkOne::class);
$this->assertEquals(42, $engine->getNumber());
}
}