Completed
Push — 1.0-phpstan ( 5ae83f )
by Kamil
27:50
created

ThemeScreenshotFactorySpec::getMatchers()   B

Complexity

Conditions 7
Paths 1

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.2222
c 0
b 0
f 0
nc 1
cc 7
eloc 10
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
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