File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 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
3232 $ fallback
3333 );
3434
35+ $ dbName = $ dbConfig ['connect_via_database ' ] ?? $ dbConfig ['database ' ];
36+
3537 $ dbDumper = static ::forDriver ($ dbConfig ['driver ' ])
3638 ->setHost ($ dbHost ?? '' )
37- ->setDbName ($ dbConfig [ ' database ' ] )
39+ ->setDbName ($ dbName )
3840 ->setUserName ($ dbConfig ['username ' ] ?? '' )
3941 ->setPassword ($ dbConfig ['password ' ] ?? '' );
4042
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()
7171 $ this ->assertEquals ('localhost-read ' , $ dumper ->getHost ());
7272 }
7373
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+
7493 /** @test */
7594 public function it_will_throw_an_exception_when_creating_an_unknown_type_of_dumper ()
7695 {
You can’t perform that action at this time.
0 commit comments