cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.46k stars 892 forks source link

Support for testing "outer" config #2234

Closed zeleznypa closed 10 months ago

zeleznypa commented 10 months ago

I'm using a Phinx as a part of the Nette framework. There is a Dependency Ijection contaier, where I can setup the Phinx configuration directly without the 'phinx.yml' file, using the setConfig method.

Unfortunately the Test command force to use the file.

https://github.com/cakephp/phinx/blob/26753bdb66827383781eb0033b34cb467da1d12c/src/Phinx/Console/Command/Test.php#L62

It will be nice to have a possibility to check the connection with this configuration. Everything that I need is to encapsulate this line like this:

if($this->hasConfig() === false) {
    $this->loadConfig($input, $output);
}
MasterOdin commented 10 months ago

Looking quickly, all the other commands make a call to $this->bootstrap($input, $output);, which then does:

https://github.com/cakephp/phinx/blob/26753bdb66827383781eb0033b34cb467da1d12c/src/Phinx/Console/Command/AbstractCommand.php#L125-L127

So yeah, no reason to have a similar if check within the test command.