Skip to content

Commit

Permalink
Merge 70834a7 into 7eb279d
Browse files Browse the repository at this point in the history
  • Loading branch information
feryardiant committed Jun 19, 2020
2 parents 7eb279d + 70834a7 commit 9c00491
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public function __construct(array $instances = [])
{
$this->resolver = new Resolver($this);

$this->set(ContainerInterface::class, $this);
$this->set(PsrContainerInterface::class, ContainerInterface::class);
$this->set(self::class, $this);
$this->set(ContainerInterface::class, self::class);
$this->set(PsrContainerInterface::class, self::class);

foreach ($instances as $id => $instance) {
$this->set($id, $instance);
Expand Down
12 changes: 8 additions & 4 deletions test/spec/Container.spec.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Projek\Container;
use Projek\Container\{ArrayContainer, ContainerInterface, Exception, NotFoundException, Resolver };
use Projek\Container\{ContainerInterface, Exception, NotFoundException };
use Psr\Container\ContainerInterface as PsrContainer;
use Stubs\ { Dummy, AbstractFoo, ConcreteBar, ServiceProvider};
use function Kahlan\describe;
Expand All @@ -19,13 +19,17 @@
}
]);

expect($m)->toBeAnInstanceOf(ContainerInterface::class);
expect($m)->toBeAnInstanceOf(PsrContainer::class);
expect($m->get(stdClass::class))->toBeAnInstanceOf(stdClass::class);
});

it('Should register it-self', function () {
expect($this->c->get(PsrContainer::class))->toBeAnInstanceOf(PsrContainer::class);
$self = [Container::class, PsrContainer::class, ContainerInterface::class];

foreach ($self as $a) {
foreach ($self as $b) {
expect($this->c->get($a))->toBeAnInstanceOf($b);
}
}
});

it('Should resolve serive provider', function () {
Expand Down

0 comments on commit 9c00491

Please sign in to comment.