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
|
|
|
|