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

SitemapUrlSpec::it_has_localization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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\Model;
13
 
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\CoreBundle\Sitemap\Model\ChangeFrequency;
16
use Sylius\Bundle\CoreBundle\Sitemap\Model\SitemapUrlInterface;
17
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
class SitemapUrlSpec extends ObjectBehavior
22
{
23
    function it_is_initializable()
24
    {
25
        $this->shouldHaveType('Sylius\Bundle\CoreBundle\Sitemap\Model\SitemapUrl');
26
    }
27
28
    function it_implements_sitemap_url_interface()
29
    {
30
        $this->shouldImplement(SitemapUrlInterface::class);
31
    }
32
33
    function it_has_localization()
34
    {
35
        $this->setLocalization('http://sylius.org/');
36
        $this->getLocalization()->shouldReturn('http://sylius.org/');
37
    }
38
39
    function it_has_last_modification(\DateTime $now)
40
    {
41
        $this->setLastModification($now);
42
        $this->getLastModification()->shouldReturn($now);
43
    }
44
45
    function it_has_change_frequency()
46
    {
47
        $this->setChangeFrequency(ChangeFrequency::always());
48
        $this->getChangeFrequency()->shouldReturn('always');
49
    }
50
51
    function it_has_priority()
52
    {
53
        $this->setPriority(0.5);
54
        $this->getPriority()->shouldReturn(0.5);
55
    }
56
57
    function it_throws_invalid_argument_exception_if_priority_wont_be_between_zero_and_one()
58
    {
59
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array(-1));
60
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array(-0.5));
61
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array(2));
62
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array(1.1));
63
    }
64
65
    function it_throws_invalid_argument_exception_if_priority_will_be_not_a_number()
66
    {
67
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array('Mike'));
68
        $this->shouldThrow(\InvalidArgumentException::class)->during('setPriority', array(true));
69
    }
70
}
71