diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index 24f01201..cb1fea20 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -14,7 +14,6 @@ use Phinx\Config\ConfigInterface; use Phinx\Config\NamespaceAwareInterface; use Phinx\Migration\AbstractMigration; -use Phinx\Migration\Manager\Environment; use Phinx\Migration\MigrationInterface; use Phinx\Seed\AbstractSeed; use Phinx\Seed\SeedInterface; @@ -46,7 +45,7 @@ class Manager protected OutputInterface $output; /** - * @var \Phinx\Migration\Manager\Environment[] + * @var \Migrations\Migration\Environment[] */ protected array $environments = []; @@ -718,7 +717,7 @@ public function seed(string $environment, ?string $seed = null): void /** * Sets the environments. * - * @param \Phinx\Migration\Manager\Environment[] $environments Environments + * @param \Migrations\Migration\Environment[] $environments Environments * @return $this */ public function setEnvironments(array $environments = []) @@ -733,7 +732,7 @@ public function setEnvironments(array $environments = []) * * @param string $name Environment Name * @throws \InvalidArgumentException - * @return \Phinx\Migration\Manager\Environment + * @return \Migrations\Migration\Environment */ public function getEnvironment(string $name): Environment { diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index 6859787f..f1399078 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -6,10 +6,11 @@ use Cake\Datasource\ConnectionManager; use DateTime; use InvalidArgumentException; +use Migrations\Db\Adapter\AdapterInterface; +use Migrations\Migration\Environment; use Migrations\Migration\Manager; use Phinx\Config\Config; use Phinx\Console\Command\AbstractCommand; -use Phinx\Db\Adapter\AdapterInterface; use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Component\Console\Input\ArrayInput; @@ -121,7 +122,7 @@ protected function getConfigWithPlugin($paths = []) * Prepares an environment for cross DBMS functional tests. * * @param array $paths The paths config to override. - * @return \Phinx\Db\Adapter\AdapterInterface + * @return \Migrations\Db\Adapter\AdapterInterface */ protected function prepareEnvironment(array $paths = []): AdapterInterface { @@ -134,12 +135,6 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface // Emulate the results of Util::parseDsn() $connectionConfig = ConnectionManager::getConfig('test'); $adapter = $connectionConfig['scheme'] ?? null; - if ($adapter === 'postgres') { - $adapter = 'pgsql'; - } - if ($adapter === 'sqlserver') { - $adapter = 'sqlsrv'; - } $adapterConfig = [ 'adapter' => $adapter, 'user' => $connectionConfig['username'], @@ -154,7 +149,7 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface $adapter = $this->manager->getEnvironment('production')->getAdapter(); // ensure the database is empty - if ($adapterConfig['adapter'] === 'pgsql') { + if ($adapterConfig['adapter'] === 'postgres') { $adapter->dropSchema('public'); $adapter->createSchema('public'); } elseif ($adapterConfig['name'] !== ':memory:') { @@ -185,7 +180,7 @@ public function testEnvironmentInheritsDataDomainOptions() public function testPrintStatusMethod() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -232,7 +227,7 @@ public function testPrintStatusMethod() public function testPrintStatusMethodJsonFormat() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -278,7 +273,7 @@ public function testPrintStatusMethodJsonFormat() public function testPrintStatusMethodWithBreakpointSet() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -325,7 +320,7 @@ public function testPrintStatusMethodWithBreakpointSet() public function testPrintStatusMethodWithNoMigrations() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); @@ -344,7 +339,7 @@ public function testPrintStatusMethodWithNoMigrations() public function testPrintStatusMethodWithMissingMigrations() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -403,7 +398,7 @@ public function testPrintStatusMethodWithMissingMigrations() public function testPrintStatusMethodWithMissingLastMigration() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -464,7 +459,7 @@ public function testPrintStatusMethodWithMissingLastMigration() public function testPrintStatusMethodWithMissingMigrationsAndBreakpointSet() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -523,7 +518,7 @@ public function testPrintStatusMethodWithMissingMigrationsAndBreakpointSet() public function testPrintStatusMethodWithDownMigrations() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -558,7 +553,7 @@ public function testPrintStatusMethodWithDownMigrations() public function testPrintStatusMethodWithMissingAndDownMigrations() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once()) @@ -656,7 +651,7 @@ public function testGetMigrationsWithInvalidMigrationClassName() public function testGettingAValidEnvironment() { $this->assertInstanceOf( - 'Phinx\Migration\Manager\Environment', + Environment::class, $this->manager->getEnvironment('production') ); } @@ -674,7 +669,7 @@ public function testGettingAValidEnvironment() public function testMigrationsByDate(array $availableMigrations, $dateString, $expectedMigration, $message) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); if (is_null($expectedMigration)) { @@ -705,7 +700,7 @@ public function testMigrationsByDate(array $availableMigrations, $dateString, $e public function testRollbackToVersion($availableRollbacks, $version, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -738,7 +733,7 @@ public function testRollbackToVersion($availableRollbacks, $version, $expectedOu public function testRollbackToDate($availableRollbacks, $version, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -771,7 +766,7 @@ public function testRollbackToDate($availableRollbacks, $version, $expectedOutpu public function testRollbackToVersionByExecutionTime($availableRollbacks, $version, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -814,7 +809,7 @@ public function testRollbackToVersionByExecutionTime($availableRollbacks, $versi public function testRollbackToVersionByName($availableRollbacks, $version, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -857,7 +852,7 @@ public function testRollbackToVersionByName($availableRollbacks, $version, $expe public function testRollbackToDateByExecutionTime($availableRollbacks, $date, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -894,7 +889,7 @@ public function testRollbackToDateByExecutionTime($availableRollbacks, $date, $e public function testRollbackToVersionWithSingleMigrationDoesNotFail() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -919,7 +914,7 @@ public function testRollbackToVersionWithSingleMigrationDoesNotFail() public function testRollbackToVersionWithTwoMigrations() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -958,7 +953,7 @@ public function testRollbackToVersionWithTwoMigrations() public function testRollbackLast($availableRolbacks, $versionOrder, $expectedOutput) { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->any()) @@ -2253,7 +2248,7 @@ public static function rollbackLastDataProvider() public function testExecuteSeedWorksAsExpected() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -2268,7 +2263,7 @@ public function testExecuteSeedWorksAsExpected() public function testExecuteASingleSeedWorksAsExpected() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -2281,7 +2276,7 @@ public function testExecuteASingleSeedWorksAsExpected() public function testExecuteANonExistentSeedWorksAsExpected() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -2303,7 +2298,7 @@ public function testOrderSeeds() public function testSeedWillNotBeExecuted() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $this->manager->setEnvironments(['mockenv' => $envStub]); @@ -2775,7 +2770,7 @@ public function testMigrationWithDropColumnAndForeignKeyAndIndex() public function testInvalidVersionBreakpoint() { // stub environment - $envStub = $this->getMockBuilder('\Phinx\Migration\Manager\Environment') + $envStub = $this->getMockBuilder(Environment::class) ->setConstructorArgs(['mockenv', []]) ->getMock(); $envStub->expects($this->once())