forked from schmittjoh/JMSDiExtraBundle
-
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 a functional test for issue schmittjoh#219.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace JMS\DiExtraBundle\Tests\Functional\Entities; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity(repositoryClass="\JMS\DiExtraBundle\Tests\Functional\Entities\TestEntityRepository") | ||
*/ | ||
class TestEntity | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private $id; | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace JMS\DiExtraBundle\Tests\Functional\Entities; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
use JMS\DiExtraBundle\Annotation as DI; | ||
|
||
class TestEntityRepository extends EntityRepository | ||
{ | ||
private $service; | ||
|
||
private $parameter; | ||
|
||
public function getService() | ||
{ | ||
return $this->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("foo_%some_parameter%") | ||
* }) | ||
*/ | ||
public function setParameter($parameter) | ||
{ | ||
$this->parameter = $parameter; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace JMS\DiExtraBundle\Tests\Functional; | ||
|
||
class Issue219Test extends BaseTestCase | ||
{ | ||
public function testDoctrineRepositoryInjection() | ||
{ | ||
$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->assertSame($kernel->getContainer()->get('some_service'), $repository->getService()); | ||
$this->assertEquals("foo_42", $repository->getParameter()); | ||
} | ||
} |
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,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 |