@@ -82,9 +82,53 @@ public function testCustomNameConfigIsWritten($format)
8282 $ this ->writeConfig (uniqid () . $ format );
8383 }
8484
85+ public function configurationOptionDataProvider (): array
86+ {
87+ return [
88+ ['phinx.php ' ],
89+ [sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'phinx.php ' ],
90+ ];
91+ }
92+
93+ /**
94+ * @dataProvider configurationOptionDataProvider
95+ */
96+ public function testConfigurationOption ($ configPath ): void
97+ {
98+ $ currentDir = getcwd ();
99+ $ expectedPath = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'phinx.php ' ;
100+ try {
101+ chdir (sys_get_temp_dir ());
102+ $ application = new PhinxApplication ();
103+ $ application ->add (new Init ());
104+ $ command = $ application ->find ('init ' );
105+ $ commandTester = new CommandTester ($ command );
106+
107+ $ command = [
108+ '--configuration ' => $ configPath ,
109+ 'command ' => $ command ->getName (),
110+ ];
111+
112+ $ exitCode = $ commandTester ->execute ($ command , ['decorated ' => false ]);
113+ $ this ->assertEquals (AbstractCommand::CODE_SUCCESS , $ exitCode );
114+
115+ $ this ->assertStringContainsString (
116+ "created $ expectedPath " ,
117+ $ commandTester ->getDisplay (),
118+ );
119+
120+ $ this ->assertFileExists (
121+ $ expectedPath ,
122+ 'Phinx configuration not existent ' ,
123+ );
124+ } finally {
125+ chdir ($ currentDir );
126+ }
127+ }
128+
85129 public function testDefaults ()
86130 {
87- $ current_dir = getcwd ();
131+ $ currentDir = getcwd ();
88132
89133 try {
90134 chdir (sys_get_temp_dir ());
@@ -107,13 +151,13 @@ public function testDefaults()
107151 'Phinx configuration not existent ' ,
108152 );
109153 } finally {
110- chdir ($ current_dir );
154+ chdir ($ currentDir );
111155 }
112156 }
113157
114158 public function testYamlFormat ()
115159 {
116- $ current_dir = getcwd ();
160+ $ currentDir = getcwd ();
117161
118162 try {
119163 chdir (sys_get_temp_dir ());
@@ -136,7 +180,7 @@ public function testYamlFormat()
136180 'Phinx configuration not existent ' ,
137181 );
138182 } finally {
139- chdir ($ current_dir );
183+ chdir ($ currentDir );
140184 }
141185 }
142186
0 commit comments