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