@@ -89,6 +89,35 @@ private function readFromFiles(string $outPath, string $errPath):array {
8989 ];
9090 }
9191
92+ public function testGetConfigMergesDefaultConfigWithProjectOverrides ():void {
93+ $ project = $ this ->createProjectDir ();
94+ $ sqlitePath = str_replace ("\\" , "/ " , $ project . DIRECTORY_SEPARATOR . "cli-test.db " );
95+ $ this ->writeConfigIni ($ project , $ sqlitePath );
96+
97+ $ defaultConfigPath = $ project . DIRECTORY_SEPARATOR . "config.default.ini " ;
98+ file_put_contents ($ defaultConfigPath , implode (PHP_EOL , [
99+ "[database] " ,
100+ "host = default-host " ,
101+ "port = 4406 " ,
102+ "migration_table = project_migrations " ,
103+ "schema = default-schema " ,
104+ ]));
105+
106+ $ command = new class extends ExecuteCommand {
107+ public function getConfigPublic (string $ repoBasePath , ?string $ defaultPath ):\Gt \Config \Config {
108+ return $ this ->getConfig ($ repoBasePath , $ defaultPath );
109+ }
110+ };
111+
112+ $ config = $ command ->getConfigPublic ($ project , $ defaultConfigPath );
113+
114+ self ::assertSame ("default-host " , $ config ->get ("database.host " ));
115+ self ::assertSame ("4406 " , $ config ->get ("database.port " ));
116+ self ::assertSame ("project_migrations " , $ config ->get ("database.migration_table " ));
117+ self ::assertSame ($ sqlitePath , $ config ->get ("database.schema " ));
118+ self ::assertSame ("sqlite " , $ config ->get ("database.driver " ));
119+ }
120+
92121 public function testExecuteMigratesAll ():void {
93122 $ project = $ this ->createProjectDir ();
94123 $ sqlitePath = str_replace ("\\" , "/ " , $ project . DIRECTORY_SEPARATOR . "cli-test.db " );
0 commit comments