Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / config / Tests / Definition / Dumper / YamlReferenceDumperTest.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\YamlReferenceDumper;
16 use Symfony\Component\Config\Tests\Fixtures\Configuration\ExampleConfiguration;
17
18 class YamlReferenceDumperTest extends TestCase
19 {
20     public function testDumper()
21     {
22         $configuration = new ExampleConfiguration();
23
24         $dumper = new YamlReferenceDumper();
25
26         $this->assertEquals($this->getConfigurationAsString(), $dumper->dump($configuration));
27     }
28
29     public function provideDumpAtPath()
30     {
31         return array(
32             'Regular node' => array('scalar_true', <<<EOL
33 scalar_true:          true
34 EOL
35             ),
36             'Array node' => array('array', <<<EOL
37 # some info
38 array:
39     child1:               ~
40     child2:               ~
41
42     # this is a long
43     # multi-line info text
44     # which should be indented
45     child3:               ~ # Example: example setting
46 EOL
47             ),
48             'Regular nested' => array('array.child2', <<<EOL
49 child2:               ~
50 EOL
51             ),
52             'Prototype' => array('cms_pages.page', <<<EOL
53 # Prototype
54 page:
55
56     # Prototype
57     locale:
58         title:                ~ # Required
59         path:                 ~ # Required
60 EOL
61             ),
62             'Nested prototype' => array('cms_pages.page.locale', <<<EOL
63 # Prototype
64 locale:
65     title:                ~ # Required
66     path:                 ~ # Required
67 EOL
68             ),
69         );
70     }
71
72     /**
73      * @dataProvider provideDumpAtPath
74      */
75     public function testDumpAtPath($path, $expected)
76     {
77         $configuration = new ExampleConfiguration();
78
79         $dumper = new YamlReferenceDumper();
80
81         $this->assertSame(trim($expected), trim($dumper->dumpAtPath($configuration, $path)));
82     }
83
84     private function getConfigurationAsString()
85     {
86         return <<<'EOL'
87 acme_root:
88     boolean:              true
89     scalar_empty:         ~
90     scalar_null:          null
91     scalar_true:          true
92     scalar_false:         false
93     scalar_default:       default
94     scalar_array_empty:   []
95     scalar_array_defaults:
96
97         # Defaults:
98         - elem1
99         - elem2
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"
106
107     # some info
108     array:
109         child1:               ~
110         child2:               ~
111
112         # this is a long
113         # multi-line info text
114         # which should be indented
115         child3:               ~ # Example: example setting
116     scalar_prototyped:    []
117     parameters:
118
119         # Prototype: Parameter name
120         name:                 ~
121     connections:
122
123         # Prototype
124         -
125             user:                 ~
126             pass:                 ~
127     cms_pages:
128
129         # Prototype
130         page:
131
132             # Prototype
133             locale:
134                 title:                ~ # Required
135                 path:                 ~ # Required
136     pipou:
137
138         # Prototype
139         name:                 []
140
141 EOL;
142     }
143 }