1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sonata Project package. |
5
|
|
|
* |
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Sonata\DoctrineORMAdminBundle\DependencyInjection\SonataDoctrineORMAdminExtension; |
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
14
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
15
|
|
|
|
16
|
|
|
class SonataDoctrineORMAdminExtensionTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var ContainerBuilder |
20
|
|
|
*/ |
21
|
|
|
protected $configuration; |
22
|
|
|
|
23
|
|
|
protected function tearDown() |
24
|
|
|
{ |
25
|
|
|
unset($this->configuration); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testEntityManagerSetFactory() |
29
|
|
|
{ |
30
|
|
|
$this->configuration = new ContainerBuilder(); |
31
|
|
|
$this->configuration->setParameter('kernel.bundles', array()); |
32
|
|
|
$loader = new SonataDoctrineORMAdminExtension(); |
33
|
|
|
$loader->load(array(), $this->configuration); |
34
|
|
|
|
35
|
|
|
$definition = $this->configuration->getDefinition('sonata.admin.entity_manager'); |
36
|
|
|
$doctrineServiceId = 'doctrine'; |
37
|
|
|
$doctrineFactoryMethod = 'getEntityManager'; |
38
|
|
|
|
39
|
|
|
if (method_exists($definition, 'getFactory')) { |
40
|
|
|
$this->assertEquals(array(new Reference($doctrineServiceId), $doctrineFactoryMethod), $definition->getFactory()); |
41
|
|
|
} else { |
42
|
|
|
$this->assertEquals($doctrineServiceId, $definition->getFactoryService()); |
|
|
|
|
43
|
|
|
$this->assertEquals($doctrineFactoryMethod, $definition->getFactoryMethod()); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.