File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
tests/FunctionalTest/DI/Bridge/Symfony Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * PHP-DI
4+ *
5+ * @link http://php-di.org/
6+ * @copyright Matthieu Napoli (http://mnapoli.fr/)
7+ * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
8+ */
9+
10+ namespace FunctionalTest \DI \Bridge \Symfony ;
11+
12+ use DI \Bridge \Symfony \SymfonyContainerBridge ;
13+ use DI \ContainerBuilder ;
14+ use FunctionalTest \DI \Bridge \Symfony \Fixtures \ContainerAwareController ;
15+
16+ class ContainerAwareInterfaceTest extends \PHPUnit_Framework_TestCase
17+ {
18+ /**
19+ * @link https://github.com/mnapoli/PHP-DI-Symfony2/issues/2
20+ */
21+ public function testContainerAware ()
22+ {
23+ $ wrapper = new SymfonyContainerBridge ();
24+ $ builder = new ContainerBuilder ();
25+ $ builder ->wrapContainer ($ wrapper );
26+ $ wrapper ->setFallbackContainer ($ builder ->build ());
27+
28+ /** @var ContainerAwareController $class */
29+ $ class = $ wrapper ->get ('FunctionalTest\DI\Bridge\Symfony\Fixtures\ContainerAwareController ' );
30+
31+ $ this ->assertSame ($ wrapper , $ class ->container );
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace FunctionalTest \DI \Bridge \Symfony \Fixtures ;
4+
5+ use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
6+ use Symfony \Component \DependencyInjection \ContainerInterface ;
7+
8+ class ContainerAwareController implements ContainerAwareInterface
9+ {
10+ public $ container ;
11+
12+ public function setContainer (ContainerInterface $ container = null )
13+ {
14+ $ this ->container = $ container ;
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments