Completed
Push — to-be-a-hat-or-not-to-be-kuhwa ( b72886...e84c48 )
by Kamil
19:11
created

TaxonFactorySpec::let()   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 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\Component\Taxonomy\Factory;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Resource\Factory\FactoryInterface;
16
use Sylius\Component\Taxonomy\Factory\TaxonFactory;
17
use Sylius\Component\Taxonomy\Factory\TaxonFactoryInterface;
18
use Sylius\Component\Taxonomy\Model\TaxonInterface;
19
20
/**
21
 * @author Mateusz Zalewski <[email protected]>
22
 */
23
final class TaxonFactorySpec extends ObjectBehavior
24
{
25
    function let(FactoryInterface $factory)
26
    {
27
        $this->beConstructedWith($factory);
28
    }
29
30
    function it_is_initializable()
31
    {
32
        $this->shouldHaveType(TaxonFactory::class);
33
    }
34
35
    function it_implements_taxon_factory_interface()
36
    {
37
        $this->shouldImplement(TaxonFactoryInterface::class);
38
    }
39
40
    function it_uses_decorated_factory_to_create_new_taxon(
41
        FactoryInterface $factory,
42
        TaxonInterface $taxon
43
    ) {
44
        $factory->createNew()->willReturn($taxon);
45
46
        $this->createNew()->shouldReturn($taxon);
47
    }
48
49
    function it_creates_taxon_for_given_parent_taxon(
50
        FactoryInterface $factory,
51
        TaxonInterface $parent,
52
        TaxonInterface $taxon
53
    ) {
54
        $factory->createNew()->willReturn($taxon);
55
        $taxon->setParent($parent)->shouldBeCalled();
56
57
        $this->createForParent($parent)->shouldReturn($taxon);
58
    }
59
}
60