|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\FixturesBundle\Suite; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Prophecy\Argument; |
|
18
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\LazySuiteRegistry; |
|
19
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteFactoryInterface; |
|
20
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteInterface; |
|
21
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteNotFoundException; |
|
22
|
|
|
use Sylius\Bundle\FixturesBundle\Suite\SuiteRegistryInterface; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @author Kamil Kokot <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
final class LazySuiteRegistrySpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function let(SuiteFactoryInterface $suiteFactory): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->beConstructedWith($suiteFactory); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_implements_suite_registry_interface(): void |
|
35
|
|
|
{ |
|
36
|
|
|
$this->shouldImplement(SuiteRegistryInterface::class); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_returns_a_constructed_suite(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite): void |
|
40
|
|
|
{ |
|
41
|
|
|
$this->addSuite('suite_name', ['fixtures' => []]); |
|
42
|
|
|
|
|
43
|
|
|
$suiteFactory->createSuite('suite_name', ['fixtures' => []])->willReturn($suite); |
|
44
|
|
|
|
|
45
|
|
|
$this->getSuite('suite_name')->shouldReturn($suite); |
|
46
|
|
|
$this->getSuites()->shouldReturn(['suite_name' => $suite]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function it_constructs_a_suite_only_once(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite): void |
|
50
|
|
|
{ |
|
51
|
|
|
$this->addSuite('suite_name', ['fixtures' => []]); |
|
52
|
|
|
|
|
53
|
|
|
$suiteFactory->createSuite('suite_name', ['fixtures' => []])->shouldBeCalledTimes(1)->willReturn($suite); |
|
54
|
|
|
|
|
55
|
|
|
$this->getSuite('suite_name')->shouldReturn($suite); |
|
56
|
|
|
$this->getSuite('suite_name')->shouldReturn($suite); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
function it_returns_an_empty_suites_list_if_none_was_registered(): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->getSuites()->shouldReturn([]); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
function it_throws_an_exception_if_trying_to_get_unexisting_suite(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->shouldThrow(SuiteNotFoundException::class)->during('getSuite', ['the_river_snake_is_dangerous']); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|