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

SitemapFactorySpec::getMatchers()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

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