File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ protected function withFreshQueryLog($callback)
214214 protected function getDefaultDatabaseName (string $ dsn , array $ config ): string
215215 {
216216 if (empty ($ config ['database ' ])) {
217- if (! preg_match ('/^mongodb(?:[+]srv)?: \\/ \\/.+ \\/([^?&]+)/s ' , $ dsn , $ matches )) {
217+ if (! preg_match ('/^mongodb(?:[+]srv)?: \\/ \\/.+? \\/([^?&]+)/s ' , $ dsn , $ matches )) {
218218 throw new InvalidArgumentException ('Database is not properly configured. ' );
219219 }
220220
Original file line number Diff line number Diff line change @@ -190,6 +190,12 @@ public static function dataConnectionConfig(): Generator
190190 'expectedDatabaseName ' => 'tests ' ,
191191 'config ' => ['dsn ' => 'mongodb://some-host:12345/tests ' ],
192192 ];
193+
194+ yield 'Database is extracted from DSN with CA path in options ' => [
195+ 'expectedUri ' => 'mongodb://some-host:12345/tests?tls=true&tlsCAFile=/path/to/ca.pem&retryWrites=false ' ,
196+ 'expectedDatabaseName ' => 'tests ' ,
197+ 'config ' => ['dsn ' => 'mongodb://some-host:12345/tests?tls=true&tlsCAFile=/path/to/ca.pem&retryWrites=false ' ],
198+ ];
193199 }
194200
195201 #[DataProvider('dataConnectionConfig ' )]
You can’t perform that action at this time.
0 commit comments