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 PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
final class SitemapDefintionTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testItIsInstantiable(): void |
18
|
|
|
{ |
19
|
|
|
$definition = new SitemapDefinition('acme.sitemap'); |
20
|
|
|
|
21
|
|
|
static::assertSame('acme.sitemap', $definition->getType()); |
22
|
|
|
static::assertSame('acme.sitemap', $definition->toString()); |
23
|
|
|
static::assertSame('acme.sitemap', $definition->__toString()); |
24
|
|
|
static::assertSame([], $definition->getSettings()); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testSetting(): void |
28
|
|
|
{ |
29
|
|
|
$definition = new SitemapDefinition('acme.sitemap'); |
30
|
|
|
$definition->setSettings([ |
31
|
|
|
'foo'=> 'bar', |
32
|
|
|
]); |
33
|
|
|
|
34
|
|
|
static::assertSame('bar', $definition->getSetting('foo')); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testSettingWithDefault(): void |
38
|
|
|
{ |
39
|
|
|
$definition = new SitemapDefinition('acme.sitemap'); |
40
|
|
|
|
41
|
|
|
static::assertSame('baz', $definition->getSetting('foo', 'baz')); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
View Code Duplication |
public function testTtl(): void |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$definition = new SitemapDefinition('acme.sitemap', [ |
47
|
|
|
'use_cache' => true, |
48
|
|
|
'ttl' => 90, |
49
|
|
|
]); |
50
|
|
|
|
51
|
|
|
static::assertSame(90, $definition->getTtl()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
View Code Duplication |
public function testTtlWithoutCache(): void |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
$definition = new SitemapDefinition('acme.sitemap', [ |
57
|
|
|
'use_cache' => false, |
58
|
|
|
]); |
59
|
|
|
|
60
|
|
|
static::assertSame(0, $definition->getTtl()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testTtlDefault(): void |
64
|
|
|
{ |
65
|
|
|
$definition = new SitemapDefinition('acme.sitemap'); |
66
|
|
|
|
67
|
|
|
static::assertSame(0, $definition->getTtl()); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.