File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,11 @@ public static function createForConnection(string $connectionName): DbDumper
32
32
$ fallback
33
33
);
34
34
35
+ $ dbName = $ dbConfig ['connect_via_database ' ] ?? $ dbConfig ['database ' ];
36
+
35
37
$ dbDumper = static ::forDriver ($ dbConfig ['driver ' ])
36
38
->setHost ($ dbHost ?? '' )
37
- ->setDbName ($ dbConfig [ ' database ' ] )
39
+ ->setDbName ($ dbName )
38
40
->setUserName ($ dbConfig ['username ' ] ?? '' )
39
41
->setPassword ($ dbConfig ['password ' ] ?? '' );
40
42
Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ public function it_will_use_the_read_db_when_one_is_defined()
71
71
$ this ->assertEquals ('localhost-read ' , $ dumper ->getHost ());
72
72
}
73
73
74
+ /** @test */
75
+ public function it_will_use_connect_via_database_when_one_is_defined ()
76
+ {
77
+ $ dbConfig = [
78
+ 'driver ' => 'pgsql ' ,
79
+ 'connect_via_database ' => 'connection_pool ' ,
80
+ 'username ' => 'root ' ,
81
+ 'password ' => 'myPassword ' ,
82
+ 'database ' => 'myDb ' ,
83
+ 'dump ' => ['add_extra_option ' => '--extra-option=value ' ],
84
+ ];
85
+
86
+ $ this ->app ['config ' ]->set ('database.connections.pgsql ' , $ dbConfig );
87
+
88
+ $ dumper = DbDumperFactory::createForConnection ('pgsql ' );
89
+
90
+ $ this ->assertEquals ('connection_pool ' , $ dumper ->getDbName ());
91
+ }
92
+
74
93
/** @test */
75
94
public function it_will_throw_an_exception_when_creating_an_unknown_type_of_dumper ()
76
95
{
You can’t perform that action at this time.
0 commit comments