diff --git a/Tests/Functional/Entities/TestEntity.php b/Tests/Functional/Entities/TestEntity.php new file mode 100644 index 0000000..a78c7c1 --- /dev/null +++ b/Tests/Functional/Entities/TestEntity.php @@ -0,0 +1,17 @@ +service; + } + + public function getParameter() + { + return $this->parameter; + } + + /** + * @DI\InjectParams({ + * "service" = @DI\Inject("some_service") + * }) + */ + public function setService($service) + { + $this->service = $service; + } + + /** + * @DI\InjectParams({ + * "parameter" = @DI\Inject("%some_parameter%") + * }) + */ + public function setParameter($parameter) + { + $this->parameter = $parameter; + } +} diff --git a/Tests/Functional/Issue219Test.php b/Tests/Functional/Issue219Test.php new file mode 100644 index 0000000..bb11b46 --- /dev/null +++ b/Tests/Functional/Issue219Test.php @@ -0,0 +1,28 @@ + false, 'config' => 'issue-219.yml')); + $kernel->boot(); + + $manager = $kernel->getContainer()->get('doctrine.orm.default_entity_manager'); + $repository = $manager->getRepository('\JMS\DiExtraBundle\Tests\Functional\Entities\TestEntity'); + + $this->assertSame($kernel->getContainer()->get('some_service'), $repository->getService()); + } + + public function testParameterInjection() + { + $kernel = static::createKernel(array('debug' => false, 'config' => 'issue-219.yml')); + $kernel->boot(); + + $manager = $kernel->getContainer()->get('doctrine.orm.default_entity_manager'); + $repository = $manager->getRepository('\JMS\DiExtraBundle\Tests\Functional\Entities\TestEntity'); + + $this->assertEquals(42, $repository->getParameter()); + } +} diff --git a/Tests/Functional/config/issue-219.yml b/Tests/Functional/config/issue-219.yml new file mode 100644 index 0000000..218f460 --- /dev/null +++ b/Tests/Functional/config/issue-219.yml @@ -0,0 +1,17 @@ +imports: + - { resource: doctrine.yml } + +doctrine: + orm: + mappings: + test_entities: + type: annotation + dir: %kernel.root_dir%/Entities + prefix: JMS\DiExtraBundle\Tests\Functional\Entities + +services: + some_service: + class: stdClass + +parameters: + some_parameter: 42