MapConverterTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 47
ccs 0
cts 35
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testMapConverter() 0 6 1
A testMatchesAnyFilenameExtension() 0 7 1
A testUnalteredContent() 0 7 1
A testMappingFilenameExtension() 0 12 1
A testExtensionNotFoundMappingTable() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Yosymfony\Spress.
5
 *
6
 * (c) YoSymfony <http://github.com/yosymfony>
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 Yosymfony\Spress\Core\Tests\ContentManager\Converter;
13
14
use PHPUnit\Framework\TestCase;
15
use Yosymfony\Spress\Core\ContentManager\Converter\MapConverter;
16
17
class MapConverterTest extends TestCase
18
{
19
    public function testMapConverter()
20
    {
21
        $converter = new MapConverter();
22
23
        $this->assertEquals(0, $converter->getPriority());
24
    }
25
26
    public function testMatchesAnyFilenameExtension()
27
    {
28
        $converter = new MapConverter();
29
30
        $this->assertTrue($converter->matches('html'));
31
        $this->assertTrue($converter->matches('md'));
32
    }
33
34
    public function testUnalteredContent()
35
    {
36
        $converter = new MapConverter();
37
38
        $this->assertEquals('<h1>This is HTML text</h1>', $converter->convert('<h1>This is HTML text</h1>'));
39
        $this->assertEquals('This is plain text', $converter->convert('This is plain text'));
40
    }
41
42
    public function testMappingFilenameExtension()
43
    {
44
        $converter = new MapConverter([
45
            'twig' => 'html',
46
            'html.twig' => 'html',
47
            'twig.html' => 'html',
48
        ]);
49
50
        $this->assertEquals('html', $converter->getOutExtension('twig'));
51
        $this->assertEquals('html', $converter->getOutExtension('html.twig'));
52
        $this->assertEquals('html', $converter->getOutExtension('twig.html'));
53
    }
54
55
    public function testExtensionNotFoundMappingTable()
56
    {
57
        $converter = new MapConverter([
58
            'twig' => 'html',
59
        ]);
60
61
        $this->assertEquals('md', $converter->getOutExtension('md'));
62
    }
63
}
64