forked from phpcfdi/cfdi-cleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepairXmlNsSchemaLocationTest.php
71 lines (65 loc) · 2.48 KB
/
RepairXmlNsSchemaLocationTest.php
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
<?php
declare(strict_types=1);
namespace PhpCfdi\CfdiCleaner\Tests\Features\XmlStringCleaners;
use PhpCfdi\CfdiCleaner\Tests\TestCase;
use PhpCfdi\CfdiCleaner\XmlStringCleaners\XmlNsSchemaLocation;
class RepairXmlNsSchemaLocationTest extends TestCase
{
/** @return array<string, array{string, string}> */
public function providerInputCases(): array
{
return [
'spaces' => [
'<root xsi:schemaLocation="http://localhost/a http://localhost/a.xsd"/>',
'<root xmlns:schemaLocation="http://localhost/a http://localhost/a.xsd"/>',
],
'tabs' => [
"<root\txsi:schemaLocation=\"http://localhost/a http://localhost/a.xsd\"/>",
"<root\txmlns:schemaLocation=\"http://localhost/a http://localhost/a.xsd\"/>",
],
'line feed' => [
"<root\nxsi:schemaLocation=\"http://localhost/a http://localhost/a.xsd\"/>",
"<root\nxmlns:schemaLocation=\"http://localhost/a http://localhost/a.xsd\"/>",
],
'first xsi then xmlns' => [
<<< EOT
<root foo="bar"
xsi:schemaLocation="http://localhost/a http://localhost/a.xsd">
</root>
EOT,
<<< EOT
<root foo="bar"
xsi:schemaLocation="http://localhost/a http://localhost/a.xsd"
xmlns:schemaLocation="with line terminators
">
</root>
EOT,
],
'first xmlns then xsi' => [
<<< EOT
<root foo="bar"
xsi:schemaLocation="http://localhost/a http://localhost/a.xsd">
</root>
EOT,
<<< EOT
<root foo="bar"
xmlns:schemaLocation="with line terminators
"
xsi:schemaLocation="http://localhost/a http://localhost/a.xsd">
</root>
EOT,
],
];
}
/**
* @param string $expected
* @param string $input
* @dataProvider providerInputCases
*/
public function testCleaning(string $expected, string $input): void
{
$cleaner = new XmlNsSchemaLocation();
$clean = $cleaner->clean($input);
$this->assertEquals($expected, $clean);
}
}