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