MarshalDelegatorsConfigTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 21
c 1
b 0
f 0
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testItShouldPrepareContainerConfigFromMarshalledDelegatorFactories() 0 29 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AntidotTest\Container;
6
7
use Antidot\Container\Container;
8
use Antidot\Container\ContainerConfig;
9
use Antidot\Container\ContainerDelegatorFactory;
10
use Antidot\Container\MarshalDelegatorsConfig;
11
use PHPUnit\Framework\TestCase;
12
use Psr\Container\ContainerInterface;
13
14
class MarshalDelegatorsConfigTest extends TestCase
15
{
16
    public function testItShouldPrepareContainerConfigFromMarshalledDelegatorFactories(): void
17
    {
18
        $config = new ContainerConfig([
19
            'config' => [],
20
            'parameters' => [],
21
            'some.service' => \SplStack::class,
22
            'delegators' => [
23
                'some.service' => [
24
                    function (ContainerInterface $container, string $name, callable $callback): \SplStack {
25
                        /** @var \SplStack $stack */
26
                        $stack = $callback();
27
                        $stack->push('Hello World!!!');
28
29
                        return $stack;
30
                    }
31
                ]
32
            ],
33
        ]);
34
35
        $marshallDelegatorConfig = new MarshalDelegatorsConfig();
36
        $marshalledConfig = $marshallDelegatorConfig($config);
37
        $this->assertTrue($marshalledConfig->has('some.service'));
38
        $this->assertIsCallable($marshalledConfig->get('some.service'));
39
        $this->assertTrue($marshalledConfig->has('delegators'));
40
        $delegators = $marshalledConfig->get('delegators');
41
        $this->assertArrayHasKey('some.service', $delegators);
42
        $this->assertIsCallable($delegators['some.service'][0]);
43
        $this->assertTrue($marshalledConfig->has(ContainerDelegatorFactory::class));
44
        $this->assertIsCallable($marshalledConfig->get(ContainerDelegatorFactory::class));
45
    }
46
}
47