Completed
Push — master ( e4a43c...c6b5e7 )
by Tomáš
15:17
created

testUnsupportedMethodsSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Symplify\NetteAdapterForSymfonyBundles\Tests;
4
5
use Nette\DI\Container;
6
use PHPUnit\Framework\TestCase;
7
use stdClass;
8
use Symplify\NetteAdapterForSymfonyBundles\SymfonyContainerAdapter;
9
10
final class SymfonyContainerAdapterTest extends TestCase
11
{
12
    /**
13
     * @var SymfonyContainerAdapter
14
     */
15
    private $symfonyContainerAdapter;
16
17
    protected function setUp()
18
    {
19
        $containerMock = $this->prophesize(Container::class);
20
        $containerMock->getParameters()->willReturn(['someParameter' => 'someValue']);
21
        $containerMock->hasService('someService')->willReturn(true);
22
        $containerMock->hasService('nonExistingService')->willReturn(false);
23
        $containerMock->getService('someService')->willReturn('service');
24
        $this->symfonyContainerAdapter = new SymfonyContainerAdapter([], $containerMock->reveal());
25
    }
26
27
    public function testParameters()
28
    {
29
        $this->assertSame('someValue', $this->symfonyContainerAdapter->getParameter('someParameter'));
30
        $this->assertTrue($this->symfonyContainerAdapter->hasParameter('someParameter'));
31
    }
32
33
    /**
34
     * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
35
     */
36
    public function testNonExistingParameters()
37
    {
38
        $this->symfonyContainerAdapter->getParameter('nonExistingParameter');
39
    }
40
41
    public function testServices()
42
    {
43
        $this->assertTrue($this->symfonyContainerAdapter->has('someService'));
44
        $this->assertSame('service', $this->symfonyContainerAdapter->get('someService'));
45
    }
46
47
    /**
48
     * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
49
     */
50
    public function testNonExistingService()
51
    {
52
        $this->assertFalse($this->symfonyContainerAdapter->has('nonExistingService'));
53
        $this->symfonyContainerAdapter->get('nonExistingService');
54
    }
55
56
    /**
57
     * @expectedException \Symplify\NetteAdapterForSymfonyBundles\Exception\UnsupportedApiException
58
     */
59
    public function testUnsupportedMethodsSet()
60
    {
61
        $this->symfonyContainerAdapter->set('someService', new stdClass());
62
    }
63
64
    /**
65
     * @expectedException \Symplify\NetteAdapterForSymfonyBundles\Exception\UnsupportedApiException
66
     */
67
    public function testUnsupportedMethodsSetParameter()
68
    {
69
        $this->symfonyContainerAdapter->setParameter('someParameter', 'someValue');
70
    }
71
72
    /**
73
     * @expectedException \Symplify\NetteAdapterForSymfonyBundles\Exception\UnsupportedApiException
74
     */
75
    public function testUnsupportedMethodsInitialized()
76
    {
77
        $this->symfonyContainerAdapter->initialized('someService');
78
    }
79
}
80