ContainerTest::testFetchingService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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