Completed
Pull Request — 3.x (#597)
by
unknown
08:33
created

SonataDoctrineORMAdminExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 4
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A testEntityManagerSetFactory() 0 18 2
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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());
0 ignored issues
show
Bug introduced by
The method getFactoryService() does not exist on Symfony\Component\DependencyInjection\Definition. Did you maybe mean getFactory()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
43
            $this->assertEquals($doctrineFactoryMethod, $definition->getFactoryMethod());
0 ignored issues
show
Bug introduced by
The method getFactoryMethod() does not exist on Symfony\Component\DependencyInjection\Definition. Did you maybe mean getFactory()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
44
        }
45
    }
46
}
47