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
|
|
|
|