-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added method updating container config
- Loading branch information
1 parent
897ace4
commit fad2eac
Showing
5 changed files
with
72 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Quillstack\DI\Tests\Mocks\Config; | ||
|
||
class MockClass | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Quillstack\DI\Tests\Mocks\Config; | ||
|
||
interface MockInterface | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Quillstack\DI\Tests\Unit; | ||
|
||
use Quillstack\DI\Container; | ||
use Quillstack\DI\Exceptions\InterfaceDefinitionNotFoundException; | ||
use Quillstack\DI\Tests\Mocks\Config\MockClass; | ||
use Quillstack\DI\Tests\Mocks\Config\MockInterface; | ||
use Quillstack\UnitTests\AssertEqual; | ||
use Quillstack\UnitTests\AssertExceptions; | ||
|
||
class TestAddToConfig | ||
{ | ||
private Container $container; | ||
|
||
public function __construct(private AssertExceptions $assertExceptions, private AssertEqual $assertEqual) | ||
{ | ||
$this->container = new Container(); | ||
} | ||
|
||
public function expectNoInterfaceInConfig() | ||
{ | ||
$this->assertExceptions->expect(InterfaceDefinitionNotFoundException::class); | ||
|
||
$this->container->get(MockInterface::class); | ||
} | ||
|
||
public function addToConfig() | ||
{ | ||
$this->container->addToConfig([ | ||
MockInterface::class => MockClass::class, | ||
]); | ||
|
||
$mockClass = $this->container->get(MockInterface::class); | ||
|
||
$this->assertEqual->equal($mockClass, new MockClass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters