Completed
Push — master ( 6c5077...d22a37 )
by Christian
01:33
created

SitemapDefintionTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testItIsInstantiable() 0 9 1
A testSetting() 0 9 1
A testSettingWithDefault() 0 6 1
A testTtl() 0 9 1
A testTtlDefault() 0 6 1
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\SitemapBundle\Tests\Definition;
11
12
use Core23\SitemapBundle\Definition\SitemapDefinition;
13
use Core23\SitemapBundle\Definition\SitemapDefinitionInterface;
14
use PHPUnit\Framework\TestCase;
15
16
class SitemapDefintionTest extends TestCase
17
{
18
    public function testItIsInstantiable(): void
19
    {
20
        $definition = new SitemapDefinition('acme.sitemap');
21
22
        $this->assertInstanceOf(SitemapDefinitionInterface::class, $definition);
23
        $this->assertSame('acme.sitemap', $definition->getType());
24
        $this->assertSame('acme.sitemap', $definition->toString());
25
        $this->assertSame([], $definition->getSettings());
26
    }
27
28
    public function testSetting(): void
29
    {
30
        $definition = new SitemapDefinition('acme.sitemap');
31
        $definition->setSettings([
32
            'foo'=> 'bar',
33
        ]);
34
35
        $this->assertSame('bar', $definition->getSetting('foo'));
36
    }
37
38
    public function testSettingWithDefault(): void
39
    {
40
        $definition = new SitemapDefinition('acme.sitemap');
41
42
        $this->assertSame('baz', $definition->getSetting('foo', 'baz'));
43
    }
44
45
    public function testTtl(): void
46
    {
47
        $definition = new SitemapDefinition('acme.sitemap', [
48
            'use_cache' => true,
49
            'ttl'       => 90,
50
        ]);
51
52
        $this->assertSame(90, $definition->getTtl());
53
    }
54
55
    public function testTtlDefault(): void
56
    {
57
        $definition = new SitemapDefinition('acme.sitemap');
58
59
        $this->assertSame(0, $definition->getTtl());
60
    }
61
}
62