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

ContainerTest::__construct()   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 League\Tactician\CommandBus;
6
use Nette\DI\Container;
7
use PHPUnit\Framework\TestCase;
8
use Symplify\NetteAdapterForSymfonyBundles\Tests\ContainerSource\AutowiredService;
9
use Symplify\NetteAdapterForSymfonyBundles\Tests\ContainerSource\SomeService;
10
11
final class ContainerTest extends TestCase
12
{
13
    /**
14
     * @var Container
15
     */
16
    private $container;
17
18
    public function __construct()
19
    {
20
        $this->container = (new ContainerFactory())->create();
21
    }
22
23
    public function testFetchingService()
24
    {
25
        $someService = $this->container->getByType(SomeService::class);
26
        $this->assertInstanceOf(SomeService::class, $someService);
27
    }
28
29
    public function testReferenceToOtherService()
30
    {
31
        $commandBus = $this->container->getByType(CommandBus::class);
32
        $this->assertInstanceOf(CommandBus::class, $commandBus);
33
    }
34
35
    public function testAutowiredService()
36
    {
37
        /** @var AutowiredService $autowiredService */
38
        $autowiredService = $this->container->getByType(AutowiredService::class);
39
        $this->assertInstanceOf(AutowiredService::class, $autowiredService);
40
        $this->assertInstanceOf(SomeService::class, $autowiredService->getSomeService());
41
    }
42
}
43