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
|
|
|
|