mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix(container): resolves dependencies without contructor
Co-Authored-By: Johannes Pichler <fetzi@users.noreply.github.com>
This commit is contained in:
@ -18,6 +18,10 @@ it('gets an instance', function () {
|
||||
assertSame($this->container, $this->container->get(Container::class));
|
||||
});
|
||||
|
||||
test('autowire', function () {
|
||||
assertInstanceOf(Container::class, $this->container->get(Container::class));
|
||||
});
|
||||
|
||||
it('creates an instance and resolves parameters', function () {
|
||||
$this->container->add(Container::class, $this->container);
|
||||
$instance = $this->container->get(ClassWithDependency::class);
|
||||
@ -39,15 +43,9 @@ it('can resolve builtin value types', function () {
|
||||
assertInstanceOf(TestSuite::class, $instance);
|
||||
});
|
||||
|
||||
it('cannot resolve a parameter that requires additional dependencies', function () {
|
||||
$this->expectException(ShouldNotHappen::class);
|
||||
$this->container->get(ClassWithDependency::class);
|
||||
});
|
||||
|
||||
it('cannot resolve a parameter without type', function () {
|
||||
$this->expectException(ShouldNotHappen::class);
|
||||
$this->container->get(ClassWithoutTypeParameter::class);
|
||||
});
|
||||
})->throws(ShouldNotHappen::class);
|
||||
|
||||
class ClassWithDependency
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user