Completed
Push — master ( 79d213...eeff33 )
by Kamil
23:15
created

CircularDependencyFoundExceptionSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_is_a_domain_exception() 0 4 1
A it_is_a_logic_exception() 0 4 1
A it_transforms_a_cycle_to_user_friendly_message() 0 15 1
A it_throws_another_exception_if_there_is_no_cycle_in_given_elements() 0 10 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\ThemeBundle\Loader;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
17
use Sylius\Bundle\ThemeBundle\Loader\CircularDependencyFoundException;
18
19
/**
20
 * @mixin CircularDependencyFoundException
21
 *
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
class CircularDependencyFoundExceptionSpec extends ObjectBehavior
25
{
26
    function let()
27
    {
28
        $this->beConstructedWith([]);
29
    }
30
31
    function it_is_initializable()
32
    {
33
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Loader\CircularDependencyFoundException');
34
    }
35
36
    function it_is_a_domain_exception()
37
    {
38
        $this->shouldHaveType(\DomainException::class);
39
    }
40
41
    function it_is_a_logic_exception()
42
    {
43
        $this->shouldHaveType(\LogicException::class);
44
    }
45
46
    function it_transforms_a_cycle_to_user_friendly_message(
47
        ThemeInterface $firstTheme,
48
        ThemeInterface $secondTheme,
49
        ThemeInterface $thirdTheme,
50
        ThemeInterface $fourthTheme
51
    ) {
52
        $this->beConstructedWith([$firstTheme, $secondTheme, $thirdTheme, $fourthTheme, $thirdTheme]);
53
54
        $firstTheme->getName()->willReturn('first/theme');
55
        $secondTheme->getName()->willReturn('second/theme');
56
        $thirdTheme->getName()->willReturn('third/theme');
57
        $fourthTheme->getName()->willReturn('fourth/theme');
58
59
        $this->getMessage()->shouldReturn('Circular dependency was found while resolving theme "first/theme", caused by cycle "third/theme -> fourth/theme -> third/theme".');
60
    }
61
62
    function it_throws_another_exception_if_there_is_no_cycle_in_given_elements(
63
        ThemeInterface $firstTheme,
64
        ThemeInterface $secondTheme,
65
        ThemeInterface $thirdTheme,
66
        ThemeInterface $fourthTheme
67
    ) {
68
        $this->beConstructedWith([$firstTheme, $secondTheme, $thirdTheme, $fourthTheme]);
69
70
        $this->shouldThrow(new \InvalidArgumentException('There is no cycle within given themes.'))->duringInstantiation();
71
    }
72
}
73