ContainerTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

4 Methods

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