Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Feb 15, 2024
1 parent 2729552 commit c0b1c00
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ final class UnionTypeInConstructorFirstTypeInParamResolvable
public function __construct(private EngineMarkOne|EngineInterface $engine)
{
}

public function getEngine(): EngineMarkOne|EngineInterface
{
return $this->engine;
}
}
32 changes: 29 additions & 3 deletions tests/Unit/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1974,17 +1974,43 @@ public function testInvalidTags(string $message, array $tags): void
new Container($config);
}

public function testArgumentNameBinding()
public function testArgumentNameBindingTyped(): void
{
$config = ContainerConfig::create()
->withDefinitions([
EngineInterface::class . '$markOne' => EngineMarkOne::class,
EngineInterface::class . '$markTwo' => EngineMarkTwo::class,
EngineInterface::class . ' $markOne' => EngineMarkOne::class,
EngineInterface::class . ' $markTwo' => EngineMarkTwo::class,
]);
$container = new Container($config);

$class = $container->get(ArgumentNameBinding::class);
$this->assertInstanceOf(EngineMarkOne::class, $class->markOne);
$this->assertInstanceOf(EngineMarkTwo::class, $class->markTwo);
}

public function testArgumentNameBindingUntyped(): void
{
$config = ContainerConfig::create()
->withDefinitions([
'$markOne' => EngineMarkOne::class,
'$markTwo' => EngineMarkTwo::class,
]);
$container = new Container($config);

$class = $container->get(ArgumentNameBinding::class);
$this->assertInstanceOf(EngineMarkOne::class, $class->markOne);
$this->assertInstanceOf(EngineMarkTwo::class, $class->markTwo);
}

public function testArgumentNameBindingUnionTypes(): void
{
$config = ContainerConfig::create()
->withDefinitions([
'$engine' => EngineMarkOne::class,
]);
$container = new Container($config);

$class = $container->get(UnionTypeInConstructorFirstTypeInParamResolvable::class);
$this->assertInstanceOf(EngineMarkOne::class, $class->getEngine());
}
}

0 comments on commit c0b1c00

Please sign in to comment.