Completed
Push — 1.2-symfony4-packages ( fadf23 )
by Kamil
70:47 queued 48:14
created

ThemeScreenshotFactorySpec   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 1
dl 0
loc 39
c 0
b 0
f 0
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
final class ThemeScreenshotFactorySpec extends ObjectBehavior
21
{
22
    function it_implements_theme_screenshot_factory_interface(): void
23
    {
24
        $this->shouldImplement(ThemeScreenshotFactoryInterface::class);
25
    }
26
27
    function it_creates_a_screenshot_from_an_array(): void
28
    {
29
        $this
30
            ->createFromArray(['path' => '/screenshot/path.jpg', 'title' => 'Steamboat', 'description' => 'With steamboat into a wonderful cruise'])
31
            ->shouldBeScreenshotWithTheFollowingProperties(['path' => '/screenshot/path.jpg', 'title' => 'Steamboat', 'description' => 'With steamboat into a wonderful cruise'])
32
        ;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getMatchers(): array
39
    {
40
        return [
41
            'beScreenshotWithTheFollowingProperties' => function (ThemeScreenshot $subject, array $properties) {
42
                if (isset($properties['path']) && $subject->getPath() !== $properties['path']) {
43
                    return false;
44
                }
45
46
                if (isset($properties['title']) && $subject->getTitle() !== $properties['title']) {
47
                    return false;
48
                }
49
50
                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...
51
                    return false;
52
                }
53
54
                return true;
55
            },
56
        ];
57
    }
58
}
59