Completed
Push — scalar-types/fixtures ( 9e7ef5 )
by Kamil
33:42 queued 09:21
created

FixtureRegistrySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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