Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aliases to help autowiring #640

Merged
merged 1 commit into from
Mar 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Resources/config/dbal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</parameters>

<services>
<service id="Doctrine\DBAL\Driver\Connection" alias="database_connection" public="false" />

<service id="doctrine.dbal.logger.chain" class="%doctrine.dbal.logger.chain.class%" public="false" abstract="true">
<call method="addLogger">
<argument type="service" id="doctrine.dbal.logger" />
Expand Down Expand Up @@ -58,6 +60,7 @@
<argument>%doctrine.default_connection%</argument>
<argument>%doctrine.default_entity_manager%</argument>
</service>
<service id="Doctrine\Common\Persistence\ManagerRegistry" alias="doctrine" public="false" />

<service id="doctrine.twig.doctrine_extension" class="Doctrine\Bundle\DoctrineBundle\Twig\DoctrineExtension" public="false">
<tag name="twig.extension" />
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
</parameters>

<services>
<service id="Doctrine\Common\Persistence\ObjectManager" alias="doctrine.orm.entity_manager" public="false" />
<service id="Doctrine\ORM\EntityManagerInterface" alias="doctrine.orm.entity_manager" public="false" />

<!--- Deprecated Annotation Metadata Reader Service alias, use annotation_reader service -->
<service id="doctrine.orm.metadata.annotation_reader" alias="annotation_reader" public="false" />

Expand Down
30 changes: 0 additions & 30 deletions Tests/RegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,36 +116,6 @@ public function testGetUnknownEntityManager()
$registry->getManager('default');
}

public function testResetDefaultEntityManager()
Copy link
Member Author

@nicolas-grekas nicolas-grekas Mar 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two tests rely on deprecated behavior, and do not test things in the bundle, be behavior in the doctrine bridge. Since it's not the responsibility of the bundle to test the bridge, they can and should be removed.

{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->any())
->method('initialized')
->with($this->equalTo('doctrine.orm.default_entity_manager'))
->willReturn(true);
$container->expects($this->once())
->method('set')
->with($this->equalTo('doctrine.orm.default_entity_manager'), $this->equalTo(null));

$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
$registry->resetManager();
}

public function testResetEntityManager()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->any())
->method('initialized')
->with($this->equalTo('doctrine.orm.default_entity_manager'))
->willReturn(true);
$container->expects($this->once())
->method('set')
->with($this->equalTo('doctrine.orm.default_entity_manager'), $this->equalTo(null));

$registry = new Registry($container, array(), array('default' => 'doctrine.orm.default_entity_manager'), 'default', 'default');
$registry->resetManager('default');
}

public function testResetUnknownEntityManager()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
Expand Down