Completed
Push — 1.0 ( 2476f6...9c5da5 )
by David
10s
created

ServiceProviderCompilationPassTest::getDiscovery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\Interop\ServiceProviderBridgeBundle;
5
6
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use TheCodingMachine\Discovery\DiscoveryInterface;
9
use TheCodingMachine\Interop\ServiceProviderBridgeBundle\Tests\Fixtures\TestServiceProvider;
10
use TheCodingMachine\Interop\ServiceProviderBridgeBundle\Tests\Fixtures\TestServiceProviderOverride;
11
use TheCodingMachine\Interop\ServiceProviderBridgeBundle\Tests\Fixtures\TestServiceProviderOverride2;
12
13
class ServiceProviderCompilationPassTest extends \PHPUnit_Framework_TestCase
14
{
15
    protected function getContainer(array $lazyArray, $useDiscovery = false)
16
    {
17
        $bundle = new InteropServiceProviderBridgeBundle($lazyArray, $useDiscovery);
18
19
        $container = new ContainerBuilder();
20
        $container->setParameter('database_host', 'localhost');
21
22
        $bundle->build($container);
23
        $container->compile();
24
        $bundle->setContainer($container);
25
        $bundle->boot();
26
        return $container;
27
    }
28
29
    /*protected function getDiscovery()
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
    {
31
        $discovery = new InMemoryDiscovery();
32
        $discovery->addBindingType(new BindingType('container-interop/service-provider'));
33
        $classBinding = new ClassBinding(TestServiceProvider::class, 'container-interop/service-provider');
34
        $discovery->addBinding($classBinding);
35
        return $discovery;
36
    }*/
37
38
    public function testSimpleServiceProvider()
39
    {
40
        $container = $this->getContainer([
41
            TestServiceProvider::class
42
        ]);
43
44
        $serviceA = $container->get('serviceA');
45
46
        $this->assertInstanceOf(\stdClass::class, $serviceA);
47
        $this->assertEquals(42, $container->get('function'));
48
    }
49
50
    public function testServiceProviderOverrides()
51
    {
52
        $container = $this->getContainer([
53
            TestServiceProvider::class,
54
            TestServiceProviderOverride::class,
55
            TestServiceProviderOverride2::class
56
        ]);
57
58
        $serviceA = $container->get('serviceA');
59
60
        $this->assertInstanceOf(\stdClass::class, $serviceA);
61
        $this->assertEquals('foo', $serviceA->newProperty);
62
        $this->assertEquals('bar', $serviceA->newProperty2);
63
    }
64
65
    /**
66
     * @expectedException \TheCodingMachine\Interop\ServiceProviderBridgeBundle\Exception\InvalidArgumentException
67
     */
68
    /*public function testExceptionMessageIfNoPuliBundle()
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
69
    {
70
        $bundle = new InteropServiceProviderBridgeBundle([], true);
71
        $container = new ContainerBuilder();
72
        $bundle->build($container);
73
        $container->compile();
74
    }*/
75
76
    /**
77
     *
78
     */
79
    /*public function testPuliBundle()
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
80
    {
81
        $container = $this->getContainer([], true);
82
83
        $serviceA = $container->get('serviceA');
84
85
        $this->assertInstanceOf(\stdClass::class, $serviceA);
86
    }*/
87
}
88