4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Tests\Definition\Dumper;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\Dumper\XmlReferenceDumper;
16 use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration;
18 class XmlReferenceDumperTest extends TestCase
20 public function testDumper()
22 $configuration = new ExampleConfiguration();
24 $dumper = new XmlReferenceDumper();
25 $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
28 public function testNamespaceDumper()
30 $configuration = new ExampleConfiguration();
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'));
36 private function getConfigurationAsString()
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" -->
51 scalar-default="default"
53 scalar-array-defaults="elem1,elem2"
56 scalar-deprecated-with-message=""
57 node-with-a-looong-name=""
58 enum-with-default="this"
64 child3: this is a long
66 which should be indented;
67 Example: example setting
76 <scalar-prototyped>scalar value</scalar-prototyped>
78 <!-- prototype: Parameter name -->
79 <parameter name="parameter name">scalar value</parameter>
88 <cms-page page="cms page page">
91 <!-- title: Required -->
92 <!-- path: Required -->
102 <pipou name="pipou name">