forked from symfony/symfony
/
XmlReferenceDumperTest.php
119 lines (98 loc) · 3.12 KB
/
XmlReferenceDumperTest.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Tests\Definition\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration;
class XmlReferenceDumperTest extends TestCase
{
public function testDumper()
{
$configuration = new ExampleConfiguration();
$dumper = new XmlReferenceDumper();
$this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
}
public function testNamespaceDumper()
{
$configuration = new ExampleConfiguration();
$dumper = new XmlReferenceDumper();
$this->assertEquals(str_replace('http://example.org/schema/dic/acme_root', 'http://symfony.com/schema/dic/symfony', $this->getConfigurationAsString()), $dumper->dump($configuration, 'http://symfony.com/schema/dic/symfony'));
}
private function getConfigurationAsString()
{
return str_replace("\n", \PHP_EOL, <<<'EOL'
<!-- Namespace: http://example.org/schema/dic/acme_root -->
<!-- scalar-required: Required -->
<!-- scalar-deprecated: Deprecated (Since vendor/package 1.1: The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
<!-- scalar-deprecated-with-message: Deprecated (Since vendor/package 1.1: Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") -->
<!-- enum-with-default: One of "this"; "that" -->
<!-- enum: One of "this"; "that" -->
<!-- variable: Example: foo, bar -->
<config
boolean="true"
scalar-empty=""
scalar-null="null"
scalar-true="true"
scalar-false="false"
scalar-default="default"
scalar-array-empty=""
scalar-array-defaults="elem1,elem2"
scalar-required=""
scalar-deprecated=""
scalar-deprecated-with-message=""
node-with-a-looong-name=""
enum-with-default="this"
enum=""
variable=""
custom-node="true"
>
<!-- some info -->
<!--
child3: this is a long
multi-line info text
which should be indented;
Example: example setting
-->
<array
child1=""
child2=""
child3=""
/>
<!-- prototype -->
<scalar-prototyped>scalar value</scalar-prototyped>
<!-- prototype: Parameter name -->
<parameter name="parameter name">scalar value</parameter>
<!-- prototype -->
<connection
user=""
pass=""
/>
<!-- prototype -->
<cms-page page="cms page page">
<!-- prototype -->
<!-- title: Required -->
<!-- path: Required -->
<page
locale="page locale"
title=""
path=""
/>
</cms-page>
<!-- prototype -->
<pipou name="pipou name">
<!-- prototype -->
<name didou="" />
</pipou>
<array-with-array-example-and-no-default-value />
</config>
EOL
);
}
}