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\Fixture; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Prophecy\Argument; |
16
|
|
|
use Sylius\Bundle\FixturesBundle\Fixture\FixtureInterface; |
17
|
|
|
use Sylius\Bundle\FixturesBundle\Fixture\FixtureNotFoundException; |
18
|
|
|
use Sylius\Bundle\FixturesBundle\Fixture\FixtureRegistry; |
19
|
|
|
use Sylius\Bundle\FixturesBundle\Fixture\FixtureRegistryInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @mixin FixtureRegistry |
23
|
|
|
* |
24
|
|
|
* @author Kamil Kokot <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
final class FixtureRegistrySpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function it_is_initializable() |
29
|
|
|
{ |
30
|
|
|
$this->shouldHaveType('Sylius\Bundle\FixturesBundle\Fixture\FixtureRegistry'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_implements_fixture_registry_interface() |
34
|
|
|
{ |
35
|
|
|
$this->shouldImplement(FixtureRegistryInterface::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_has_a_fixtures(FixtureInterface $fixture) |
39
|
|
|
{ |
40
|
|
|
$fixture->getName()->willReturn('fixture'); |
41
|
|
|
|
42
|
|
|
$this->addFixture($fixture); |
43
|
|
|
|
44
|
|
|
$this->getFixture('fixture')->shouldReturn($fixture); |
45
|
|
|
$this->getFixtures()->shouldReturn(['fixture' => $fixture]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_throws_an_exception_if_trying_to_another_fixture_with_the_same_name( |
49
|
|
|
FixtureInterface $fixture, |
50
|
|
|
FixtureInterface $anotherFixture |
51
|
|
|
) { |
52
|
|
|
$fixture->getName()->willReturn('fixture'); |
53
|
|
|
$anotherFixture->getName()->willReturn('fixture'); |
54
|
|
|
|
55
|
|
|
$this->addFixture($fixture); |
56
|
|
|
$this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$fixture]); |
57
|
|
|
$this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$anotherFixture]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
function it_returns_an_empty_fixtures_list_if_it_does_not_have_any_fixtures() |
61
|
|
|
{ |
62
|
|
|
$this->getFixtures()->shouldReturn([]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
function it_throws_an_exception_if_trying_to_get_unexisting_fixture_by_name() |
66
|
|
|
{ |
67
|
|
|
$this->shouldThrow(FixtureNotFoundException::class)->during('getFixture', ['fixture']); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|