Completed
Push — master ( da2f6e...d3b8cb )
by Kamil
20:06
created

SitemapUrlFactorySpec::getMatchers()   B

Complexity

Conditions 6
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 8.8571
cc 6
eloc 9
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\CoreBundle\Sitemap\Factory;
13
 
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\CoreBundle\Sitemap\Factory\SitemapUrlFactoryInterface;
16
use Sylius\Bundle\CoreBundle\Sitemap\Model\SitemapUrlInterface;
17
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
class SitemapUrlFactorySpec extends ObjectBehavior
22
{
23
    function it_is_initializable()
24
    {
25
        $this->shouldHaveType('Sylius\Bundle\CoreBundle\Sitemap\Factory\SitemapUrlFactory');
26
    }
27
28
    function it_implements_sitemap_url_factory_interface()
29
    {
30
        $this->shouldImplement(SitemapUrlFactoryInterface::class);
31
    }
32
33
    function it_creates_empty_sitemap_url(SitemapUrlInterface $sitemapUrl)
34
    {
35
        $sitemapUrl->getLastModification()->willReturn(null);
36
        $sitemapUrl->getLocalization()->willReturn(null);
37
        $sitemapUrl->getPriority()->willReturn(null);
38
        $sitemapUrl->getChangeFrequency()->willReturn('');
39
40
        $this->createNew()->shouldBeSameAs($sitemapUrl);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getMatchers()
47
    {
48
        return [
49
            'beSameAs' => function ($subject, $key) {
50
                if (!$subject instanceof SitemapUrlInterface || !$key instanceof SitemapUrlInterface) {
51
                    return false;
52
                }
53
54
                return $subject->getChangeFrequency() === $key->getChangeFrequency()
55
                    && $subject->getLocalization() === $key->getLocalization()
56
                    && $subject->getLastModification() === $key->getLastModification()
57
                    && $subject->getPriority() === $key->getPriority();
58
            },
59
        ];
60
    }
61
}
62