@@ -44,15 +44,19 @@ public function testThrowIfEmptyNameGivenOnConstruction()
4444
4545 public function testShouldAllowAddConfigurationAsStringDsn ()
4646 {
47- $ transport = new TransportFactory ('default ' );
4847 $ tb = new TreeBuilder ();
4948 $ rootNode = $ tb ->root ('foo ' );
5049
51- $ transport ->addTransportConfiguration ($ rootNode );
50+ $ rootNode ->append (TransportFactory ::getConfiguration ());
51+
5252 $ processor = new Processor ();
53- $ config = $ processor ->process ($ tb ->buildTree (), [' dsn:// ' ]);
53+ $ config = $ processor ->process ($ tb ->buildTree (), [[ ' transport ' => ' dsn:// '] ]);
5454
55- $ this ->assertEquals (['dsn ' => 'dsn:// ' ], $ config );
55+ $ this ->assertEquals ([
56+ 'transport ' => [
57+ 'dsn ' => 'dsn:// ' ,
58+ ],
59+ ], $ config );
5660 }
5761
5862 /**
@@ -62,191 +66,209 @@ public function testShouldAllowAddConfigurationAsStringDsn()
6266 */
6367 public function testShouldAllowAddConfigurationAsDsnWithoutSlashes ()
6468 {
65- $ transport = new TransportFactory ('default ' );
6669 $ tb = new TreeBuilder ();
6770 $ rootNode = $ tb ->root ('foo ' );
6871
69- $ transport ->addTransportConfiguration ($ rootNode );
72+ $ rootNode ->append (TransportFactory ::getConfiguration ());
73+
7074 $ processor = new Processor ();
71- $ config = $ processor ->process ($ tb ->buildTree (), [' dsn: ' ]);
75+ $ config = $ processor ->process ($ tb ->buildTree (), [[ ' transport ' => ' dsn: '] ]);
7276
73- $ this ->assertEquals (['dsn ' => 'dsn: ' ], $ config );
77+ $ this ->assertEquals ([
78+ 'transport ' => [
79+ 'dsn ' => 'dsn: ' ,
80+ ],
81+ ], $ config );
7482 }
7583
7684 public function testShouldSetNullTransportIfNullGiven ()
7785 {
78- $ transport = new TransportFactory ('default ' );
7986 $ tb = new TreeBuilder ();
8087 $ rootNode = $ tb ->root ('foo ' );
8188
82- $ transport ->addTransportConfiguration ($ rootNode );
89+ $ rootNode ->append (TransportFactory ::getConfiguration ());
90+
8391 $ processor = new Processor ();
92+ $ config = $ processor ->process ($ tb ->buildTree (), [['transport ' => null ]]);
8493
85- $ config = $ processor ->process ($ tb ->buildTree (), [null ]);
86- $ this ->assertEquals (['dsn ' => 'null: ' ], $ config );
94+ $ this ->assertEquals ([
95+ 'transport ' => [
96+ 'dsn ' => 'null: ' ,
97+ ],
98+ ], $ config );
8799 }
88100
89101 public function testShouldSetNullTransportIfEmptyStringGiven ()
90102 {
91- $ transport = new TransportFactory ('default ' );
92103 $ tb = new TreeBuilder ();
93104 $ rootNode = $ tb ->root ('foo ' );
94105
95- $ transport ->addTransportConfiguration ($ rootNode );
106+ $ rootNode ->append (TransportFactory ::getConfiguration ());
107+
96108 $ processor = new Processor ();
109+ $ config = $ processor ->process ($ tb ->buildTree (), [['transport ' => '' ]]);
97110
98- $ config = $ processor ->process ($ tb ->buildTree (), ['' ]);
99- $ this ->assertEquals (['dsn ' => 'null: ' ], $ config );
111+ $ this ->assertEquals ([
112+ 'transport ' => [
113+ 'dsn ' => 'null: ' ,
114+ ],
115+ ], $ config );
100116 }
101117
102118 public function testShouldSetNullTransportIfEmptyArrayGiven ()
103119 {
104- $ transport = new TransportFactory ('default ' );
105120 $ tb = new TreeBuilder ();
106121 $ rootNode = $ tb ->root ('foo ' );
107122
108- $ transport ->addTransportConfiguration ($ rootNode );
123+ $ rootNode ->append (TransportFactory ::getConfiguration ());
124+
109125 $ processor = new Processor ();
126+ $ config = $ processor ->process ($ tb ->buildTree (), [['transport ' => []]]);
110127
111- $ config = $ processor ->process ($ tb ->buildTree (), [[]]);
112- $ this ->assertEquals (['dsn ' => 'null: ' ], $ config );
128+ $ this ->assertEquals ([
129+ 'transport ' => [
130+ 'dsn ' => 'null: ' ,
131+ ],
132+ ], $ config );
113133 }
114134
115135 public function testThrowIfEmptyDsnGiven ()
116136 {
117- $ transport = new TransportFactory ('default ' );
118137 $ tb = new TreeBuilder ();
119138 $ rootNode = $ tb ->root ('foo ' );
120139
121- $ transport ->addTransportConfiguration ($ rootNode );
122- $ processor = new Processor ();
140+ $ rootNode ->append (TransportFactory ::getConfiguration ());
123141
142+ $ processor = new Processor ();
124143 $ this ->expectException (InvalidConfigurationException::class);
125- $ this ->expectExceptionMessage ('The path "foo.dsn" cannot contain an empty value, but got "". ' );
126- $ processor ->process ($ tb ->buildTree (), [['dsn ' => '' ]]);
144+ $ this ->expectExceptionMessage ('The path "foo.transport. dsn" cannot contain an empty value, but got "". ' );
145+ $ processor ->process ($ tb ->buildTree (), [['transport ' => [ ' dsn ' => '' ] ]]);
127146 }
128147
129148 public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime ()
130149 {
131- $ transport = new TransportFactory ('default ' );
132150 $ tb = new TreeBuilder ();
133151 $ rootNode = $ tb ->root ('foo ' );
134152
135- $ transport ->addTransportConfiguration ($ rootNode );
153+ $ rootNode ->append (TransportFactory ::getConfiguration ());
154+
136155 $ processor = new Processor ();
137156
138157 $ this ->expectException (\LogicException::class);
139158 $ this ->expectExceptionMessage ('Both options factory_class and factory_service are set. Please choose one. ' );
140159 $ processor ->process ($ tb ->buildTree (), [[
141- 'dsn ' => 'foo: ' ,
142- 'factory_class ' => 'aFactoryClass ' ,
143- 'factory_service ' => 'aFactoryService ' ,
144- ]]);
160+ 'transport ' => [
161+ 'dsn ' => 'foo: ' ,
162+ 'factory_class ' => 'aFactoryClass ' ,
163+ 'factory_service ' => 'aFactoryService ' ,
164+ ]]]);
145165 }
146166
147167 public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTime ()
148168 {
149- $ transport = new TransportFactory ('default ' );
150169 $ tb = new TreeBuilder ();
151170 $ rootNode = $ tb ->root ('foo ' );
152171
153- $ transport ->addTransportConfiguration ($ rootNode );
172+ $ rootNode ->append (TransportFactory ::getConfiguration ());
173+
154174 $ processor = new Processor ();
155175
156176 $ this ->expectException (\LogicException::class);
157177 $ this ->expectExceptionMessage ('The option connection_factory_class must not be used with factory_class or factory_service at the same time. Please choose one. ' );
158178 $ processor ->process ($ tb ->buildTree (), [[
159- 'dsn ' => 'foo: ' ,
160- 'connection_factory_class ' => 'aFactoryClass ' ,
161- 'factory_service ' => 'aFactoryService ' ,
162- ]]);
179+ 'transport ' => [
180+ 'dsn ' => 'foo: ' ,
181+ 'connection_factory_class ' => 'aFactoryClass ' ,
182+ 'factory_service ' => 'aFactoryService ' ,
183+ ]]]);
163184 }
164185
165186 public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSameTime ()
166187 {
167- $ transport = new TransportFactory ('default ' );
168188 $ tb = new TreeBuilder ();
169189 $ rootNode = $ tb ->root ('foo ' );
170190
171- $ transport -> addTransportConfiguration ( $ rootNode );
191+ $ rootNode -> append ( TransportFactory :: getConfiguration () );
172192 $ processor = new Processor ();
173193
174194 $ this ->expectException (\LogicException::class);
175195 $ this ->expectExceptionMessage ('The option connection_factory_class must not be used with factory_class or factory_service at the same time. Please choose one. ' );
176196 $ processor ->process ($ tb ->buildTree (), [[
177- 'dsn ' => 'foo: ' ,
178- 'connection_factory_class ' => 'aFactoryClass ' ,
179- 'factory_service ' => 'aFactoryService ' ,
180- ]]);
197+ 'transport ' => [
198+ 'dsn ' => 'foo: ' ,
199+ 'connection_factory_class ' => 'aFactoryClass ' ,
200+ 'factory_service ' => 'aFactoryService ' ,
201+ ]]]);
181202 }
182203
183204 public function testShouldAllowSetFactoryClass ()
184205 {
185- $ transport = new TransportFactory ('default ' );
186206 $ tb = new TreeBuilder ();
187207 $ rootNode = $ tb ->root ('foo ' );
188208
189- $ transport -> addTransportConfiguration ( $ rootNode );
209+ $ rootNode -> append ( TransportFactory :: getConfiguration () );
190210 $ processor = new Processor ();
191211
192212 $ config = $ processor ->process ($ tb ->buildTree (), [[
193- 'dsn ' => 'foo: ' ,
194- 'factory_class ' => 'theFactoryClass ' ,
195- ]]);
213+ 'transport ' => [
214+ 'dsn ' => 'foo: ' ,
215+ 'factory_class ' => 'theFactoryClass ' ,
216+ ]]]);
196217
197- $ this ->assertArrayHasKey ('factory_class ' , $ config );
198- $ this ->assertSame ('theFactoryClass ' , $ config ['factory_class ' ]);
218+ $ this ->assertArrayHasKey ('factory_class ' , $ config[ ' transport ' ] );
219+ $ this ->assertSame ('theFactoryClass ' , $ config ['transport ' ][ ' factory_class ' ]);
199220 }
200221
201222 public function testShouldAllowSetFactoryService ()
202223 {
203- $ transport = new TransportFactory ('default ' );
204224 $ tb = new TreeBuilder ();
205225 $ rootNode = $ tb ->root ('foo ' );
206226
207- $ transport -> addTransportConfiguration ( $ rootNode );
227+ $ rootNode -> append ( TransportFactory :: getConfiguration () );
208228 $ processor = new Processor ();
209229
210230 $ config = $ processor ->process ($ tb ->buildTree (), [[
211- 'dsn ' => 'foo: ' ,
212- 'factory_service ' => 'theFactoryService ' ,
213- ]]);
231+ 'transport ' => [
232+ 'dsn ' => 'foo: ' ,
233+ 'factory_service ' => 'theFactoryService ' ,
234+ ]]]);
214235
215- $ this ->assertArrayHasKey ('factory_service ' , $ config );
216- $ this ->assertSame ('theFactoryService ' , $ config ['factory_service ' ]);
236+ $ this ->assertArrayHasKey ('factory_service ' , $ config[ ' transport ' ] );
237+ $ this ->assertSame ('theFactoryService ' , $ config ['transport ' ][ ' factory_service ' ]);
217238 }
218239
219240 public function testShouldAllowSetConnectionFactoryClass ()
220241 {
221- $ transport = new TransportFactory ('default ' );
222242 $ tb = new TreeBuilder ();
223243 $ rootNode = $ tb ->root ('foo ' );
224244
225- $ transport -> addTransportConfiguration ( $ rootNode );
245+ $ rootNode -> append ( TransportFactory :: getConfiguration () );
226246 $ processor = new Processor ();
227247
228248 $ config = $ processor ->process ($ tb ->buildTree (), [[
229- 'dsn ' => 'foo: ' ,
230- 'connection_factory_class ' => 'theFactoryClass ' ,
231- ]]);
249+ 'transport ' => [
250+ 'dsn ' => 'foo: ' ,
251+ 'connection_factory_class ' => 'theFactoryClass ' ,
252+ ]]]);
232253
233- $ this ->assertArrayHasKey ('connection_factory_class ' , $ config );
234- $ this ->assertSame ('theFactoryClass ' , $ config ['connection_factory_class ' ]);
254+ $ this ->assertArrayHasKey ('connection_factory_class ' , $ config[ ' transport ' ] );
255+ $ this ->assertSame ('theFactoryClass ' , $ config ['transport ' ][ ' connection_factory_class ' ]);
235256 }
236257
237258 public function testThrowIfExtraOptionGiven ()
238259 {
239- $ transport = new TransportFactory ('default ' );
240260 $ tb = new TreeBuilder ();
241261 $ rootNode = $ tb ->root ('foo ' );
242262
243- $ transport -> addTransportConfiguration ( $ rootNode );
263+ $ rootNode -> append ( TransportFactory :: getConfiguration () );
244264 $ processor = new Processor ();
245265
246- $ config = $ processor ->process ($ tb ->buildTree (), [['dsn ' => 'foo: ' , 'extraOption ' => 'aVal ' ]]);
247- $ this ->assertEquals (
248- ['dsn ' => 'foo: ' , 'extraOption ' => 'aVal ' ],
249- $ config
266+ $ config = $ processor ->process ($ tb ->buildTree (), [['transport ' => ['dsn ' => 'foo: ' , 'extraOption ' => 'aVal ' ]]]);
267+ $ this ->assertEquals ([
268+ 'transport ' => [
269+ 'dsn ' => 'foo: ' ,
270+ 'extraOption ' => 'aVal ' ,
271+ ]], $ config
250272 );
251273 }
252274
0 commit comments