5bc961bab65cf046fdf702a132c2561603d022b7
[yaffs-website] / vendor / symfony / config / Tests / Definition / Dumper / XmlReferenceDumperTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Config\Tests\Definition\Dumper;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
16 use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration;
17
18 class XmlReferenceDumperTest extends TestCase
19 {
20     public function testDumper()
21     {
22         $configuration = new ExampleConfiguration();
23
24         $dumper = new XmlReferenceDumper();
25         $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
26     }
27
28     public function testNamespaceDumper()
29     {
30         $configuration = new ExampleConfiguration();
31
32         $dumper = new XmlReferenceDumper();
33         $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'));
34     }
35
36     private function getConfigurationAsString()
37     {
38         return str_replace("\n", PHP_EOL, <<<'EOL'
39 <!-- Namespace: http://example.org/schema/dic/acme_root -->
40 <!-- scalar-required: Required -->
41 <!-- scalar-deprecated: Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
42 <!-- scalar-deprecated-with-message: Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root") -->
43 <!-- enum-with-default: One of "this"; "that" -->
44 <!-- enum: One of "this"; "that" -->
45 <config
46     boolean="true"
47     scalar-empty=""
48     scalar-null="null"
49     scalar-true="true"
50     scalar-false="false"
51     scalar-default="default"
52     scalar-array-empty=""
53     scalar-array-defaults="elem1,elem2"
54     scalar-required=""
55     scalar-deprecated=""
56     scalar-deprecated-with-message=""
57     node-with-a-looong-name=""
58     enum-with-default="this"
59     enum=""
60 >
61
62     <!-- some info -->
63     <!--
64         child3: this is a long
65                 multi-line info text
66                 which should be indented;
67                 Example: example setting
68     -->
69     <array
70         child1=""
71         child2=""
72         child3=""
73     />
74
75     <!-- prototype -->
76     <scalar-prototyped>scalar value</scalar-prototyped>
77
78     <!-- prototype: Parameter name -->
79     <parameter name="parameter name">scalar value</parameter>
80
81     <!-- prototype -->
82     <connection
83         user=""
84         pass=""
85     />
86
87     <!-- prototype -->
88     <cms-page page="cms page page">
89
90         <!-- prototype -->
91         <!-- title: Required -->
92         <!-- path: Required -->
93         <page
94             locale="page locale"
95             title=""
96             path=""
97         />
98
99     </cms-page>
100
101     <!-- prototype -->
102     <pipou name="pipou name">
103
104         <!-- prototype -->
105         <name didou="" />
106
107     </pipou>
108
109 </config>
110
111 EOL
112         );
113     }
114 }