Completed
Push — remove-pamil-phpspec-generator ( 3b9465...f51036 )
by Kamil
24:18 queued 05:52
created

SuiteSpec::createGenerator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
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 PhpSpec\Wrapper\Collaborator;
16
use Prophecy\Argument;
17
use Sylius\Bundle\FixturesBundle\Fixture\FixtureInterface;
18
use Sylius\Bundle\FixturesBundle\Suite\Suite;
19
use Sylius\Bundle\FixturesBundle\Suite\SuiteInterface;
20
21
/**
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
final class SuiteSpec extends ObjectBehavior
25
{
26
    function let()
27
    {
28
        $this->beConstructedWith('suite_name');
29
    }
30
31
    function it_is_initializable()
32
    {
33
        $this->shouldHaveType(Suite::class);
34
    }
35
36
    function it_implements_suite_interface()
37
    {
38
        $this->shouldImplement(SuiteInterface::class);
39
    }
40
41
    function it_has_name()
42
    {
43
        $this->getName()->shouldReturn('suite_name');
44
    }
45
46
    function it_has_no_fixtures_by_default()
47
    {
48
        $this->getFixtures()->shouldIterateAs([]);
49
    }
50
51
    function it_allows_for_adding_a_fixture(FixtureInterface $fixture)
52
    {
53
        $this->addFixture($fixture, []);
54
55
        $this->getFixtures()->shouldHaveKey($fixture);
56
    }
57
58
    function it_stores_a_fixture_with_its_options(FixtureInterface $fixture)
59
    {
60
        $this->addFixture($fixture, ['fixture_option' => 'fixture_name']);
61
62
        $this->getFixtures()->shouldHaveKeyWithValue($fixture, ['fixture_option' => 'fixture_name']);
63
    }
64
65
    function it_stores_multiple_fixtures_as_queue(FixtureInterface $firstFixture, FixtureInterface $secondFixture)
66
    {
67
        $this->addFixture($firstFixture, []);
68
        $this->addFixture($secondFixture, []);
69
70
        $this->getFixtures()->shouldIterateAs($this->createGenerator($firstFixture, $secondFixture));
71
    }
72
73
    function it_keeps_the_priority_of_fixtures(
74
        FixtureInterface $regularFixture,
75
        FixtureInterface $higherPriorityFixture,
76
        FixtureInterface $lowerPriorityFixture
77
    ) {
78
        $this->addFixture($regularFixture, []);
79
        $this->addFixture($higherPriorityFixture, [], 10);
80
        $this->addFixture($lowerPriorityFixture, [], -10);
81
82
        $this->getFixtures()->shouldIterateAs($this->createGenerator($higherPriorityFixture, $regularFixture, $lowerPriorityFixture));
83
    }
84
85
    /**
86
     * @param Collaborator[] ...$collaborators
87
     *
88
     * @return \Generator
89
     */
0 ignored issues
show
Documentation introduced by
Should the type for parameter $collaborators not be Collaborator[][]?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
90
    private function createGenerator(Collaborator ...$collaborators) {
91
        foreach ($collaborators as $collaborator) {
92
            yield $collaborator->getWrappedObject() => [];
93
        }
94
    }
95
}
96