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\YamlReferenceDumper;
16 use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration;
18 class YamlReferenceDumperTest extends TestCase
20 public function testDumper()
22 $configuration = new ExampleConfiguration();
24 $dumper = new YamlReferenceDumper();
26 $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
29 public function provideDumpAtPath()
32 'Regular node' => array('scalar_true', <<<EOL
36 'Array node' => array('array', <<<EOL
43 # multi-line info text
44 # which should be indented
45 child3: ~ # Example: example setting
48 'Regular nested' => array('array.child2', <<<EOL
52 'Prototype' => array('cms_pages.page', <<<EOL
62 'Nested prototype' => array('cms_pages.page.locale', <<<EOL
73 * @dataProvider provideDumpAtPath
75 public function testDumpAtPath($path, $expected)
77 $configuration = new ExampleConfiguration();
79 $dumper = new YamlReferenceDumper();
81 $this->assertSame(trim($expected), trim($dumper->dumpAtPath($configuration, $path)));
84 private function getConfigurationAsString()
93 scalar_default: default
94 scalar_array_empty: []
95 scalar_array_defaults:
100 scalar_required: ~ # Required
101 scalar_deprecated: ~ # Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.)
102 scalar_deprecated_with_message: ~ # Deprecated (Deprecation custom message for "scalar_deprecated_with_message" at "acme_root")
103 node_with_a_looong_name: ~
104 enum_with_default: this # One of "this"; "that"
105 enum: ~ # One of "this"; "that"
113 # multi-line info text
114 # which should be indented
115 child3: ~ # Example: example setting
116 scalar_prototyped: []
119 # Prototype: Parameter name