Completed
Push — master ( 4207f0...333332 )
by Kamil
23:19 queued 01:42
created

ThemeFactorySpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
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
namespace spec\Sylius\Bundle\ThemeBundle\Factory;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Factory\ThemeFactory;
17
use Sylius\Bundle\ThemeBundle\Factory\ThemeFactoryInterface;
18
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
19
20
/**
21
 * @mixin ThemeFactory
22
 *
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
class ThemeFactorySpec extends ObjectBehavior
26
{
27
    function let(
28
        $themeClassName = 'Sylius\Bundle\ThemeBundle\Model\Theme',
29
        PropertyAccessorInterface $propertyAccessor
30
    ) {
31
        $this->beConstructedWith($themeClassName, $propertyAccessor);
32
    }
33
    
34
    function it_is_initializable()
35
    {
36
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Factory\ThemeFactory');
37
    }
38
39
    function it_implements_theme_factory_interface()
40
    {
41
        $this->shouldImplement(ThemeFactoryInterface::class);
42
    }
43
44
    function it_creates_theme_from_valid_array($themeClassName, PropertyAccessorInterface $propertyAccessor)
45
    {
46
        $data = [
47
            'name' => 'Foo bar',
48
            'slug' => 'foo/bar',
49
        ];
50
51
        $propertyAccessor->setValue(Argument::any(), 'name', 'Foo bar')->shouldBeCalled();
0 ignored issues
show
Bug introduced by
\Prophecy\Argument::any() cannot be passed to setvalue() as the parameter $objectOrArray expects a reference.
Loading history...
52
        $propertyAccessor->setValue(Argument::any(), 'slug', 'foo/bar')->shouldBeCalled();
0 ignored issues
show
Bug introduced by
\Prophecy\Argument::any() cannot be passed to setvalue() as the parameter $objectOrArray expects a reference.
Loading history...
53
        $propertyAccessor->setValue(Argument::any(), 'parentsSlugs', [])->shouldBeCalled();
0 ignored issues
show
Bug introduced by
\Prophecy\Argument::any() cannot be passed to setvalue() as the parameter $objectOrArray expects a reference.
Loading history...
54
55
        $this->createFromArray($data)->shouldHaveType($themeClassName);
56
    }
57
58
    function it_throws_exception_if_given_array_is_invalid()
59
    {
60
        $data = [
61
            'name' => 'Foo bar',
62
        ];
63
64
        $this->shouldThrow('\Exception')->duringCreateFromArray($data);
65
    }
66
}
67