File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ public static function createConfig(array $config)
2727 $ config [$ key ]['port ' ] = $ dsn ->getPort ();
2828 $ config [$ key ]['user ' ] = $ dsn ->getUser ();
2929 $ config [$ key ]['pass ' ] = $ dsn ->getPassword ();
30- $ config [$ key ]['database ' ] = $ dsn ->getPath ();
30+ if (null !== $ path = $ dsn ->getPath ()) {
31+ $ path = ltrim ($ path , '/ ' );
32+ }
33+
34+ $ config [$ key ]['database ' ] = $ path ;
3135 unset($ config [$ key ]['dsn ' ]);
3236 }
3337 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace BM \BackupManagerBundle \Tests \Unit \DependencyInjection ;
4+
5+ use BM \BackupManagerBundle \Factory \ConfigFactory ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ class ConfigFactoryTest extends TestCase
9+ {
10+ public function testDsnConfig ()
11+ {
12+ $ config = ConfigFactory::createConfig (['acme ' =>['dsn ' => 'mysql://user:pass@server:3306/database ' ]]);
13+ $ this ->assertEquals ('mysql ' , $ config ->get ('acme ' , 'type ' ));
14+ $ this ->assertEquals ('server ' , $ config ->get ('acme ' , 'host ' ));
15+ $ this ->assertEquals ('3306 ' , $ config ->get ('acme ' , 'port ' ));
16+ $ this ->assertEquals ('user ' , $ config ->get ('acme ' , 'user ' ));
17+ $ this ->assertEquals ('pass ' , $ config ->get ('acme ' , 'pass ' ));
18+ $ this ->assertEquals ('database ' , $ config ->get ('acme ' , 'database ' ));
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments