@@ -113,6 +113,31 @@ public function testDbalLoadFromXmlSingleConnections(): void
113
113
$ this ->assertEquals ('5.6.20 ' , $ config ['serverVersion ' ]);
114
114
}
115
115
116
+ public function testDbalLoadUrlOverride (): void
117
+ {
118
+ $ container = $ this ->loadContainer ('dbal_allow_url_override ' );
119
+
120
+ // doctrine.dbal.mysql_connection
121
+ $ config = $ container ->getDefinition ('doctrine.dbal.default_connection ' )->getArgument (0 );
122
+
123
+ $ this ->assertSame ('mysql://root:password@database:3306/main?serverVersion=mariadb-10.5.8 ' , $ config ['url ' ]);
124
+
125
+ $ expectedOverrides = [
126
+ 'dbname ' => 'main_test ' ,
127
+ 'host ' => 'docker ' ,
128
+ 'port ' => 4321 ,
129
+ 'user ' => 'tester ' ,
130
+ 'password ' => 'wordpass ' ,
131
+ ];
132
+
133
+ foreach ($ expectedOverrides as $ param => $ value ) {
134
+ $ this ->assertSame ($ value , $ config [$ param ]);
135
+ }
136
+
137
+ $ this ->assertSame ($ expectedOverrides , $ config ['connection_override_options ' ]);
138
+ $ this ->assertFalse (isset ($ config ['override_url ' ]));
139
+ }
140
+
116
141
public function testDbalLoadSingleMasterSlaveConnection (): void
117
142
{
118
143
$ container = $ this ->loadContainer ('dbal_service_single_master_slave_connection ' );
@@ -135,6 +160,7 @@ class_exists(PrimaryReadReplicaConnection::class) ?
135
160
'dbname ' => 'mysql_db ' ,
136
161
'host ' => 'localhost ' ,
137
162
'unix_socket ' => '/path/to/mysqld.sock ' ,
163
+ 'connection_override_options ' => [],
138
164
],
139
165
$ param ['primary ' ] ?? $ param ['master ' ] // TODO: Remove 'master' support here when we require dbal >= 2.11
140
166
);
@@ -169,6 +195,7 @@ public function testDbalLoadPoolShardingConnection(): void
169
195
'dbname ' => 'mysql_db ' ,
170
196
'host ' => 'localhost ' ,
171
197
'unix_socket ' => '/path/to/mysqld.sock ' ,
198
+ 'connection_override_options ' => [],
172
199
],
173
200
$ param ['global ' ]
174
201
);
@@ -223,6 +250,7 @@ public function testLoadSimpleSingleConnection(): void
223
250
'driver ' => 'pdo_mysql ' ,
224
251
'driverOptions ' => [],
225
252
'defaultTableOptions ' => [],
253
+ 'connection_override_options ' => [],
226
254
],
227
255
new Reference ('doctrine.dbal.default_connection.configuration ' ),
228
256
new Reference ('doctrine.dbal.default_connection.event_manager ' ),
@@ -262,6 +290,7 @@ public function testLoadSimpleSingleConnectionWithoutDbName(): void
262
290
'driver ' => 'pdo_mysql ' ,
263
291
'driverOptions ' => [],
264
292
'defaultTableOptions ' => [],
293
+ 'connection_override_options ' => [],
265
294
],
266
295
new Reference ('doctrine.dbal.default_connection.configuration ' ),
267
296
new Reference ('doctrine.dbal.default_connection.event_manager ' ),
@@ -302,6 +331,7 @@ public function testLoadSingleConnection(): void
302
331
'dbname ' => 'sqlite_db ' ,
303
332
'memory ' => true ,
304
333
'defaultTableOptions ' => [],
334
+ 'connection_override_options ' => [],
305
335
],
306
336
new Reference ('doctrine.dbal.default_connection.configuration ' ),
307
337
new Reference ('doctrine.dbal.default_connection.event_manager ' ),
0 commit comments