Completed
Push — develop ( 9f43d2...2581dc )
by Filipe
01:49
created

ContainerBuilderSpec::it_creates_empty_containers()   A

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
namespace spec\Slick\Di;
4
5
use Slick\Di\ContainerInterface;
6
use Slick\Di\ContainerAwareInterface;
7
use Slick\Di\ContainerBuilder;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
11
class ContainerBuilderSpec extends ObjectBehavior
12
{
13
    function it_is_initializable()
14
    {
15
        $this->shouldHaveType(ContainerBuilder::class);
16
    }
17
18
    function its_container_aware()
19
    {
20
        $this->shouldBeAnInstanceOf(ContainerAwareInterface::class);
21
    }
22
23
    function it_creates_empty_containers()
24
    {
25
        $this->beConstructedWith();
26
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
27
    }
28
29
    function it_hydrates_a_container_with_an_array_of_definitions(ContainerInterface $container)
30
    {
31
        $services = [
32
            'foo' => 'bar',
33
            'baz' => '@foo'
34
        ];
35
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(2);
36
        $this->beConstructedWith($services);
37
        $this->setContainer($container);
38
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
39
    }
40
41
    function it_hydrates_a_container_with_an_array_from_a_file(ContainerInterface $container)
42
    {
43
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(3);
44
        $this->beConstructedWith(__DIR__ .'/services/services1.php');
45
        $this->setContainer($container);
46
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
47
    }
48
49
    function it_hydrates_a_container_with_all_arrays_form_the_files_within_a_directory(ContainerInterface $container)
50
    {
51
        $container->register(Argument::type('string'), Argument::any())->shouldBeCalledTimes(6);
52
        $this->beConstructedWith(__DIR__ .'/services');
53
        $this->setContainer($container);
54
        $this->getContainer()->shouldBeAnInstanceOf(ContainerInterface::class);
55
    }
56
57
}
58