forked from clue/php-viewvc-api-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoaderTest.php
More file actions
72 lines (58 loc) · 1.73 KB
/
LoaderTest.php
File metadata and controls
72 lines (58 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
use Clue\React\ViewVcApi\Io\Loader;
class LoaderTest extends TestCase
{
private $loader;
public function setUp()
{
$this->loader = new Loader();
}
/**
* @dataProvider xmlFiles
* @param string $path
*/
public function testValidXmlFixtures($path)
{
$xml = $this->loader->loadXmlFile(__DIR__ . '/../fixtures/' . $path);
}
public function xmlFiles()
{
return array_filter(array_map(
function ($path) {
return (substr($path, -5) === '.html') ? array($path) : null;
},
scandir(__DIR__ . '/../fixtures/')
));
}
public function testHtmlEntities()
{
$str = '<p>ä… ©</p>';
$xml = $this->loader->loadXmlString($str);
// c3 a4 e2 80 a6 c2 a0 c2 a9
$this->assertEquals('ä… ©', (string)$xml);
}
public function testMixedEncodings()
{
// mixed UTF-8 and ISO-8859-1
$str = "<p>ä and \xFC</p>";
$xml = $this->loader->loadXmlString($str);
$this->assertEquals('ä and ü', (string)$xml);
}
public function testLoadInvalidMarkupInputNotClosed()
{
$str = '<input type="hidden">';
$xml = $this->loader->loadXmlString($str);
$this->assertEquals('hidden', (string)$xml['type']);
}
public function testPrepareInvalidMarkupBrNotClosed()
{
$html = '<br>';
$xml = $this->loader->loadXmlString($html);
}
public function testLoadInvalidMarkupSelectedAttributeNoValue()
{
$str = '<option selected>this</option>';
$xml = $this->loader->loadXmlString($str);
$this->assertEquals('selected', (string)$xml['selected']);
}
}