Completed
Push — 1.0-composer-lock ( 289cb2 )
by Kamil
33:52
created

ThemeScreenshotFactorySpec   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_implements_theme_screenshot_factory_interface() 0 4 1
A it_creates_a_screenshot_from_an_array() 0 7 1
B getMatchers() 0 20 7
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\ThemeBundle\Factory;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\ThemeBundle\Factory\ThemeScreenshotFactoryInterface;
18
use Sylius\Bundle\ThemeBundle\Model\ThemeScreenshot;
19
20
/**
21
 * @author Kamil Kokot <[email protected]>
22
 */
23
final class ThemeScreenshotFactorySpec extends ObjectBehavior
24
{
25
    function it_implements_theme_screenshot_factory_interface(): void
26
    {
27
        $this->shouldImplement(ThemeScreenshotFactoryInterface::class);
28
    }
29
30
    function it_creates_a_screenshot_from_an_array(): void
31
    {
32
        $this
33
            ->createFromArray(['path' => '/screenshot/path.jpg', 'title' => 'Steamboat', 'description' => 'With steamboat into a wonderful cruise'])
34
            ->shouldBeScreenshotWithTheFollowingProperties(['path' => '/screenshot/path.jpg', 'title' => 'Steamboat', 'description' => 'With steamboat into a wonderful cruise'])
35
        ;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getMatchers(): array
42
    {
43
        return [
44
            'beScreenshotWithTheFollowingProperties' => function (ThemeScreenshot $subject, array $properties) {
45
                if (isset($properties['path']) && $subject->getPath() !== $properties['path']) {
46
                    return false;
47
                }
48
49
                if (isset($properties['title']) && $subject->getTitle() !== $properties['title']) {
50
                    return false;
51
                }
52
53
                if (isset($properties['description']) && $subject->getDescription() !== $properties['description']) {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !(isset($properti...erties['description']);.
Loading history...
54
                    return false;
55
                }
56
57
                return true;
58
            },
59
        ];
60
    }
61
}
62