Skip to content

Commit

Permalink
Get remaining Migrations tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 12, 2024
1 parent 02e70e1 commit 43cbd5f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
10 changes: 0 additions & 10 deletions src/Migration/BuiltinBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@
*/
namespace Migrations\Migration;

use Cake\Command\Command;
use Cake\Console\Arguments;
use Cake\Console\ConsoleIo;
use Cake\Console\TestSuite\StubConsoleInput;
use Cake\Console\TestSuite\StubConsoleOutput;
use Cake\Datasource\ConnectionManager;
use DateTime;
use InvalidArgumentException;
use Migrations\Command\StatusCommand;
use Phinx\Config\Config;
use Phinx\Config\ConfigInterface;
use Phinx\Db\Adapter\WrapperInterface;
use Migrations\Migration\Manager;
use RuntimeException;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down Expand Up @@ -108,7 +99,6 @@ public function __construct(array $default = [])
* - `connection` The datasource connection to use
* - `source` The folder where migrations are in
* - `plugin` The plugin containing the migrations
*
* @return array The migrations list and their statuses
*/
public function status(array $options = []): array
Expand Down
23 changes: 20 additions & 3 deletions src/Migration/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
use Phinx\Util\Util;
use Psr\Container\ContainerInterface;
use RuntimeException;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;

class Manager
{
Expand Down Expand Up @@ -848,7 +850,12 @@ function ($phpFile) {

$io->verbose("Constructing <info>$class</info>.");

$input = new ArgvInput();
$config = $this->getConfig();
$input = new ArrayInput([
'--plugin' => $config['plugin'],
'--source' => $config['source'],
'--connection' => $config->getConnection(),
]);
$output = new OutputAdapter($io);

// instantiate it
Expand Down Expand Up @@ -957,7 +964,17 @@ public function getSeeds(): array
/** @var \Phinx\Seed\SeedInterface[] $seeds */
$seeds = [];

$input = new ArgvInput();
$config = $this->getConfig();
$optionDef = new InputDefinition([
new InputOption('plugin', mode: InputOption::VALUE_OPTIONAL, default: ''),
new InputOption('connection', mode: InputOption::VALUE_OPTIONAL, default: ''),
new InputOption('source', mode: InputOption::VALUE_OPTIONAL, default: ''),
]);
$input = new ArrayInput([
'--plugin' => $config['plugin'],
'--connection' => $config->getConnection(),
'--source' => $config['source'],
], $optionDef);
$output = new OutputAdapter($this->io);

foreach ($phpFiles as $filePath) {
Expand Down
2 changes: 2 additions & 0 deletions src/Migration/ManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public function createConfig(): ConfigInterface
],
'migration_base_class' => 'Migrations\AbstractMigration',
'environment' => $adapterConfig,
'plugin' => $plugin,
'source' => (string)$this->getOption('source'),

Check failure on line 122 in src/Migration/ManagerFactory.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Double space found
// TODO do we want to support the DI container in migrations?
];

Expand Down
6 changes: 0 additions & 6 deletions src/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@

use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use DateTime;
use InvalidArgumentException;
use Migrations\Migration\BuiltinBackend;
use Migrations\Migration\PhinxBackend;
use Phinx\Config\Config;
use Phinx\Config\ConfigInterface;
use Phinx\Db\Adapter\WrapperInterface;
use Phinx\Migration\Manager;
use RuntimeException;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -32,8 +28,6 @@
/**
* The Migrations class is responsible for handling migrations command
* within an none-shell application.
*
* TODO(mark) This needs to be adapted to use the configure backend selection.
*/
class Migrations
{
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Cake\TestSuite\TestCase;
use Exception;
use InvalidArgumentException;
use Migrations\CakeAdapter;
use Migrations\Migrations;
use Phinx\Config\FeatureFlags;
use Phinx\Db\Adapter\WrapperInterface;
Expand Down Expand Up @@ -127,7 +126,7 @@ public static function backendProvider(): array
{
return [
['builtin'],
['phinx']
['phinx'],
];
}

Expand Down

0 comments on commit 43cbd5f

Please sign in to comment.