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

ThemeFactorySpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 42
rs 10
c 3
b 0
f 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_implements_theme_factory_interface() 0 4 1
A let() 0 6 1
A it_creates_theme_from_valid_array() 0 13 1
A it_throws_exception_if_given_array_is_invalid() 0 8 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\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