Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

LazySuiteRegistrySpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
lcom 0
cbo 3
dl 0
loc 47
rs 10
c 2
b 0
f 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_suite_registry_interface() 0 4 1
A it_returns_an_empty_suites_list_if_none_was_registered() 0 4 1
A it_throws_an_exception_if_trying_to_get_unexisting_suite() 0 4 1
A it_returns_a_constructed_suite() 0 9 1
A it_constructs_a_suite_only_once() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Bundle\FixturesBundle\Suite;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\FixturesBundle\Suite\LazySuiteRegistry;
17
use Sylius\Bundle\FixturesBundle\Suite\SuiteFactoryInterface;
18
use Sylius\Bundle\FixturesBundle\Suite\SuiteInterface;
19
use Sylius\Bundle\FixturesBundle\Suite\SuiteNotFoundException;
20
use Sylius\Bundle\FixturesBundle\Suite\SuiteRegistryInterface;
21
22
/**
23
 * @mixin LazySuiteRegistry
24
 *
25
 * @author Kamil Kokot <[email protected]>
26
 */
27
final class LazySuiteRegistrySpec extends ObjectBehavior
28
{
29
    function let(SuiteFactoryInterface $suiteFactory)
30
    {
31
        $this->beConstructedWith($suiteFactory);
32
    }
33
34
    function it_is_initializable()
35
    {
36
        $this->shouldHaveType('Sylius\Bundle\FixturesBundle\Suite\LazySuiteRegistry');
37
    }
38
39
    function it_implements_suite_registry_interface()
40
    {
41
        $this->shouldImplement(SuiteRegistryInterface::class);
42
    }
43
44
    function it_returns_a_constructed_suite(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite)
45
    {
46
        $this->addSuite('suite_name', ['fixtures' => []]);
47
48
        $suiteFactory->createSuite('suite_name', ['fixtures' => []])->willReturn($suite);
49
50
        $this->getSuite('suite_name')->shouldReturn($suite);
51
        $this->getSuites()->shouldReturn(['suite_name' => $suite]);
52
    }
53
54
    function it_constructs_a_suite_only_once(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite)
55
    {
56
        $this->addSuite('suite_name', ['fixtures' => []]);
57
58
        $suiteFactory->createSuite('suite_name', ['fixtures' => []])->shouldBeCalledTimes(1)->willReturn($suite);
59
60
        $this->getSuite('suite_name')->shouldReturn($suite);
61
        $this->getSuite('suite_name')->shouldReturn($suite);
62
    }
63
64
    function it_returns_an_empty_suites_list_if_none_was_registered()
65
    {
66
        $this->getSuites()->shouldReturn([]);
67
    }
68
69
    function it_throws_an_exception_if_trying_to_get_unexisting_suite()
70
    {
71
        $this->shouldThrow(SuiteNotFoundException::class)->during('getSuite', ['the_river_snake_is_dangerous']);
72
    }
73
}
74