-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
TagReference::id()
method + Improve docs (#380)
* Add `TagReference::makeId()` method + Improve docs * Apply fixes from StyleCI * Update README.md Co-authored-by: Alexey Rogachev <[email protected]> * Update README.md Co-authored-by: Alexey Rogachev <[email protected]> * Update README.md Co-authored-by: Alexey Rogachev <[email protected]> * Update src/Reference/TagReference.php Co-authored-by: Alexey Rogachev <[email protected]> * Update src/Reference/TagReference.php Co-authored-by: Alexander Makarov <[email protected]> * fix --------- Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Alexey Rogachev <[email protected]> Co-authored-by: Alexander Makarov <[email protected]>
- Loading branch information
1 parent
0dee6c5
commit 4faab46
Showing
8 changed files
with
104 additions
and
13 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
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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Di\Tests\Unit\Reference\TagReference\Resolve; | ||
|
||
final class A | ||
{ | ||
} |
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,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Di\Tests\Unit\Reference\TagReference\Resolve; | ||
|
||
final class B | ||
{ | ||
} |
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 Yiisoft\Di\Tests\Unit\Reference\TagReference\Resolve; | ||
|
||
final class Main | ||
{ | ||
public array $data = []; | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/Unit/Reference/TagReference/Resolve/TagReferenceResolveTest.php
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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Di\Tests\Unit\Reference\TagReference\Resolve; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Di\Container; | ||
use Yiisoft\Di\ContainerConfig; | ||
use Yiisoft\Di\Reference\TagReference; | ||
|
||
final class TagReferenceResolveTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$container = new Container( | ||
ContainerConfig::create() | ||
->withDefinitions([ | ||
Main::class => [ | ||
'$data' => TagReference::to('letters'), | ||
], | ||
]) | ||
->withTags([ | ||
'letters' => [A::class, B::class], | ||
]) | ||
); | ||
|
||
$main = $container->get(Main::class); | ||
|
||
$this->assertCount(2, $main->data); | ||
$this->assertInstanceOf(A::class, $main->data[0]); | ||
$this->assertInstanceOf(B::class, $main->data[1]); | ||
} | ||
} |
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