diff --git a/bin/yii-db-migration b/bin/yii-db-migration index 92537b78..0af63b2c 100644 --- a/bin/yii-db-migration +++ b/bin/yii-db-migration @@ -35,10 +35,10 @@ require $_composer_autoload_path ?? $rootPath . '/vendor/autoload.php'; * historyTable: string, * migrationNameLimit: int|null, * maxSqlOutputLength: int|null, - * createNamespace: string, - * createPath: string, - * updateNamespaces: list, - * updatePaths: list, + * newMigrationNamespace: string, + * newMigrationPath: string, + * sourceNamespaces: list, + * sourcePaths: list, * } $params */ $params = require $rootPath . '/yii-db-migration.php'; @@ -60,10 +60,10 @@ $downRunner = new DownRunner($migrator); $updateRunner = new UpdateRunner($migrator); $migrationService = new MigrationService($aliases, $db, $injector, $migrator); -$migrationService->setCreateNamespace($params['createNamespace']); -$migrationService->setCreatePath($params['createPath']); -$migrationService->setUpdateNamespaces($params['updateNamespaces']); -$migrationService->setUpdatePaths($params['updatePaths']); +$migrationService->setNewMigrationNamespace($params['newMigrationNamespace']); +$migrationService->setNewMigrationPath($params['newMigrationPath']); +$migrationService->setSourceNamespaces($params['sourceNamespaces']); +$migrationService->setSourcePaths($params['sourcePaths']); $application = new Application('Yii Database Migration Tool', '1.0.0'); $application->addCommands([ diff --git a/bin/yii-db-migration.php b/bin/yii-db-migration.php index 0f56446a..b8f36b0e 100644 --- a/bin/yii-db-migration.php +++ b/bin/yii-db-migration.php @@ -20,24 +20,25 @@ /** * Namespace of new migration classes. */ - 'createNamespace' => '', + 'newMigrationNamespace' => '', /** * List of namespaces containing the migration classes. */ - 'updateNamespaces' => [], + 'sourceNamespaces' => [], /** * Path to the directory for new migration classes. This path is used when you are using migrations without * namespaces. */ - 'createPath' => '', + 'newMigrationPath' => '', /** - * List of directories containing the migration classes. Migration classes located at this paths should be declared - * without a namespace. Use "updateNamespaces" option in case you are using namespaced migrations. + * List of directories containing the migration classes. + * Migration classes located at these paths should be declared without a namespace. + * Use the "sourceNamespaces" option in case you are using namespaced migrations. */ - 'updatePaths' => [], + 'sourcePaths' => [], /** * The name of the database table for storing migration history information. @@ -51,7 +52,7 @@ /** * Indicates whether the table names generated should consider the `tablePrefix` setting of the DB connection. - * For example, if the table name is `post` the generator will return `{{%post}}`. + * For example, if the table name is `post`, the generator will return `{{%post}}`. */ 'useTablePrefix' => true, @@ -61,7 +62,7 @@ 'container' => null, /** - * The maximum length of a SQL output in console. + * The maximum length of an SQL output in console. */ 'maxSqlOutputLength' => null, ]; diff --git a/config/di-console.php b/config/di-console.php index 06d5345c..0242e23f 100644 --- a/config/di-console.php +++ b/config/di-console.php @@ -11,10 +11,10 @@ return [ MigrationService::class => [ 'class' => MigrationService::class, - 'setCreateNamespace()' => [$params['yiisoft/db-migration']['createNamespace']], - 'setUpdateNamespaces()' => [$params['yiisoft/db-migration']['updateNamespaces']], - 'setCreatePath()' => [$params['yiisoft/db-migration']['createPath']], - 'setUpdatePaths()' => [$params['yiisoft/db-migration']['updatePaths']], + 'setNewMigrationNamespace()' => [$params['yiisoft/db-migration']['newMigrationNamespace']], + 'setSourceNamespaces()' => [$params['yiisoft/db-migration']['sourceNamespaces']], + 'setNewMigrationPath()' => [$params['yiisoft/db-migration']['newMigrationPath']], + 'setSourcePaths()' => [$params['yiisoft/db-migration']['sourcePaths']], ], MigrationInformerInterface::class => ConsoleMigrationInformer::class, diff --git a/config/params.php b/config/params.php index c51e8ef1..30b895f4 100644 --- a/config/params.php +++ b/config/params.php @@ -22,9 +22,9 @@ ], 'yiisoft/db-migration' => [ - 'createNamespace' => '', - 'createPath' => '', - 'updateNamespaces' => [], - 'updatePaths' => [], + 'newMigrationNamespace' => '', + 'newMigrationPath' => '', + 'sourceNamespaces' => [], + 'sourcePaths' => [], ], ]; diff --git a/docs/en/usage-with-symfony.md b/docs/en/usage-with-symfony.md index 408d9711..53883c15 100644 --- a/docs/en/usage-with-symfony.md +++ b/docs/en/usage-with-symfony.md @@ -25,10 +25,10 @@ Yiisoft\Injector\Injector: Yiisoft\Db\Migration\Service\MigrationService: calls: - - setCreateNamespace: ['App\Migrations'] - - setCreatePath: [''] - - setUpdateNamespaces: [['App\Migrations']] - - setUpdatePaths: [[]] + - setNewMigrationNamespace: ['App\Migrations'] + - setNewMigrationPath: [''] + - setSourceNamespaces: [['App\Migrations']] + - setSourcePaths: [[]] Yiisoft\Db\: resource: '../vendor/yiisoft/db/src/' diff --git a/docs/en/usage-with-yii-console.md b/docs/en/usage-with-yii-console.md index f355f645..97f4e2c2 100644 --- a/docs/en/usage-with-yii-console.md +++ b/docs/en/usage-with-yii-console.md @@ -27,8 +27,8 @@ Add to `config/params.php`: ```php ... 'yiisoft/db-migration' => [ - 'createNamespace' => 'App\\Migration', - 'updateNamespaces' => ['App\\Migration'], + 'newMigrationNamespace' => 'App\\Migration', + 'sourceNamespaces' => ['App\\Migration'], ], ... ``` diff --git a/src/Command/CreateCommand.php b/src/Command/CreateCommand.php index 207dc90a..73016f23 100644 --- a/src/Command/CreateCommand.php +++ b/src/Command/CreateCommand.php @@ -29,14 +29,14 @@ * * This command creates a new migration using the available migration template. * - * To use it, configure migrations paths (`createPath` and `updatePaths`) in `params.php` file, in your application. + * To use it, configure migrations paths (`newMigrationPath` and `sourcePaths`) in `params.php` file, in your application. * * ```php * 'yiisoft/db-migration' => [ - * 'createNamespace' => '', - * 'createPath' => '', - * 'updateNamespaces' => [], - * 'updatePaths' => [], + * 'newMigrationNamespace' => '', + * 'newMigrationPath' => '', + * 'sourceNamespaces' => [], + * 'sourcePaths' => [], * ], * ``` * @@ -47,7 +47,7 @@ * ./yii migrate:create table --command=table * ``` * - * In order to generate a namespaced migration, you should specify a namespace before the migration's name. + * To generate a namespaced migration, you should specify a namespace before the migration's name. * * Note that backslash (`\`) is usually considered a special character in the shell, so you need to escape it properly * to avoid shell errors or incorrect behavior. @@ -59,7 +59,8 @@ * ./yii migrate:create post --command=table --path=@root/migrations/blog * ``` * - * In case {@see $createPath} is not set and no namespace is provided, {@see $createNamespace} will be used. + * In case {@see MigrationService::$newMigrationPath} is not set, and no namespace is provided, + * {@see MigrationService::$newMigrationNamespace} will be used. */ #[AsCommand('migrate:create', 'Creates a new migration.')] final class CreateCommand extends Command @@ -101,10 +102,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespace = $input->getOption('namespace'); if ($path !== null || $namespace !== null) { - $this->migrationService->setCreatePath((string) $path); - $this->migrationService->setCreateNamespace((string) $namespace); + $this->migrationService->setNewMigrationPath((string) $path); + $this->migrationService->setNewMigrationNamespace((string) $namespace); } else { - $namespace = $this->migrationService->getCreateNamespace(); + $namespace = $this->migrationService->getNewMigrationNamespace(); } if ($this->migrationService->before(self::getDefaultName() ?? '') === Command::INVALID) { diff --git a/src/Command/NewCommand.php b/src/Command/NewCommand.php index 40074d27..0924f5a4 100644 --- a/src/Command/NewCommand.php +++ b/src/Command/NewCommand.php @@ -66,8 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespaces = $input->getOption('namespace'); if (!empty($paths) || !empty($namespaces)) { - $this->migrationService->setUpdatePaths($paths); - $this->migrationService->setUpdateNamespaces($namespaces); + $this->migrationService->setSourcePaths($paths); + $this->migrationService->setSourceNamespaces($namespaces); } $this->migrationService->before(self::getDefaultName() ?? ''); diff --git a/src/Command/UpdateCommand.php b/src/Command/UpdateCommand.php index a38a80ec..10f37327 100644 --- a/src/Command/UpdateCommand.php +++ b/src/Command/UpdateCommand.php @@ -70,8 +70,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespaces = $input->getOption('namespace'); if (!empty($paths) || !empty($namespaces)) { - $this->migrationService->setUpdatePaths($paths); - $this->migrationService->setUpdateNamespaces($namespaces); + $this->migrationService->setSourcePaths($paths); + $this->migrationService->setSourceNamespaces($namespaces); } if ($this->migrationService->before(self::getDefaultName() ?? '') === Command::INVALID) { diff --git a/src/MigrationBuilder.php b/src/MigrationBuilder.php index 5847ccfb..91c9091a 100644 --- a/src/MigrationBuilder.php +++ b/src/MigrationBuilder.php @@ -178,9 +178,9 @@ public function delete(string $table, array|string $condition = '', array $param } /** - * Builds and executes a SQL statement for creating a new DB table. + * Builds and executes an SQL statement for creating a new DB table. * - * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name + * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name * stands for a column name which will be properly quoted by the method, and definition stands for the column type * which can contain an abstract DB type. * diff --git a/src/Service/MigrationService.php b/src/Service/MigrationService.php index 01eea9a8..322df7cc 100644 --- a/src/Service/MigrationService.php +++ b/src/Service/MigrationService.php @@ -45,12 +45,12 @@ final class MigrationService { - private string $createNamespace = ''; - private string $createPath = ''; + private string $newMigrationNamespace = ''; + private string $newMigrationPath = ''; /** @var string[] */ - private array $updateNamespaces = []; + private array $sourceNamespaces = []; /** @var string[] */ - private array $updatePaths = []; + private array $sourcePaths = []; private string $version = '1.0'; private ?SymfonyStyle $io = null; @@ -70,8 +70,8 @@ public function setIo(?SymfonyStyle $io): void /** * This method is invoked right before an action is to be executed (after all possible filters.) * - * It checks the existence of the {@see $createPath}, {@see $updatePaths}, {@see $createNamespace}, - * {@see $updateNamespaces}. + * It checks the existence of the {@see $newMigrationPath}, {@see $sourcePaths}, {@see $newMigrationNamespace}, + * {@see $sourceNamespaces}. * * @return int Whether the action should continue to be executed. */ @@ -79,26 +79,26 @@ public function before(string $commandName): int { switch ($commandName) { case 'migrate:create': - if (empty($this->createNamespace) && empty($this->createPath)) { + if (empty($this->newMigrationNamespace) && empty($this->newMigrationPath)) { $this->io?->error( - 'One of `createNamespace` or `createPath` should be specified.' + 'One of `newMigrationNamespace` or `newMigrationPath` should be specified.' ); return Command::INVALID; } - if (!empty($this->createNamespace) && !empty($this->createPath)) { + if (!empty($this->newMigrationNamespace) && !empty($this->newMigrationPath)) { $this->io?->error( - 'Only one of `createNamespace` or `createPath` should be specified.' + 'Only one of `newMigrationNamespace` or `newMigrationPath` should be specified.' ); return Command::INVALID; } break; case 'migrate:up': - if (empty($this->updateNamespaces) && empty($this->updatePaths)) { + if (empty($this->sourceNamespaces) && empty($this->sourcePaths)) { $this->io?->error( - 'At least one of `updateNamespaces` or `updatePaths` should be specified.' + 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.' ); return Command::INVALID; @@ -126,30 +126,30 @@ public function getNewMigrations(): array $migrationPaths = []; - foreach ($this->updatePaths as $path) { + foreach ($this->sourcePaths as $path) { $migrationPaths[] = [$path, '']; } - foreach ($this->updateNamespaces as $namespace) { + foreach ($this->sourceNamespaces as $namespace) { $migrationPaths[] = [$this->getNamespacePath($namespace), $namespace]; } $migrations = []; foreach ($migrationPaths as $item) { - [$updatePath, $namespace] = $item; - $updatePath = $this->aliases->get($updatePath); + [$sourcePath, $namespace] = $item; + $sourcePath = $this->aliases->get($sourcePath); - if (!is_dir($updatePath)) { + if (!is_dir($sourcePath)) { continue; } - $handle = opendir($updatePath); + $handle = opendir($sourcePath); while (($file = readdir($handle)) !== false) { if ($file === '.' || $file === '..') { continue; } - $path = $updatePath . DIRECTORY_SEPARATOR . $file; + $path = $sourcePath . DIRECTORY_SEPARATOR . $file; if (is_file($path) && preg_match('/^(M(\d{12}).*)\.php$/s', $file, $matches)) { [, $class, $time] = $matches; @@ -182,9 +182,9 @@ public function getNewMigrations(): array * * @psalm-param string[] $value */ - public function setUpdateNamespaces(array $value): void + public function setSourceNamespaces(array $value): void { - $this->updateNamespaces = $value; + $this->sourceNamespaces = $value; } /** @@ -193,23 +193,23 @@ public function setUpdateNamespaces(array $value): void * This can be either a [path alias](guide:concept-aliases) or a directory path. * * Migration classes located at this path should be declared without a namespace. - * Use {@see $createNamespace} property in case you are using namespaced migrations. + * Use {@see $newMigrationNamespace} property in case you are using namespaced migrations. * - * If you have set up {@see $createNamespace}, you may set this field to `null` in order to disable usage of migrations + * If you have set up {@see $newMigrationNamespace}, you may set this field to `null` in order to disable usage of migrations * that are not namespaced. * - * In general, to load migrations from different locations, {@see $createNamespace} is the preferable solution as the + * In general, to load migrations from different locations, {@see $newMigrationNamespace} is the preferable solution as the * migration name contains the origin of the migration in the history, which is not the case when using multiple * migration paths. * * - * {@see $createNamespace} + * {@see $newMigrationNamespace} * * @psalm-param string[] $value */ - public function setUpdatePaths(array $value): void + public function setSourcePaths(array $value): void { - $this->updatePaths = $value; + $this->sourcePaths = $value; } public function version(): string @@ -237,7 +237,7 @@ private function makeMigrationInstance(string $class): object if (!str_contains($class, '\\')) { $isIncluded = false; - foreach ($this->updatePaths as $path) { + foreach ($this->sourcePaths as $path) { $file = $this->aliases->get($path) . DIRECTORY_SEPARATOR . $class . '.php'; if (is_file($file)) { @@ -315,14 +315,14 @@ public function makeRevertibleMigrations(array $classes): array ); } - public function setCreateNamespace(string $value): void + public function setNewMigrationNamespace(string $value): void { - $this->createNamespace = $value; + $this->newMigrationNamespace = $value; } - public function setCreatePath(string $value): void + public function setNewMigrationPath(string $value): void { - $this->createPath = $value; + $this->newMigrationPath = $value; } /** @@ -330,9 +330,9 @@ public function setCreatePath(string $value): void * * @return string */ - public function getCreateNamespace(): string + public function getNewMigrationNamespace(): string { - return $this->createNamespace; + return $this->newMigrationNamespace; } /** @@ -355,9 +355,9 @@ public function generateClassName(string $name): string */ public function findMigrationPath(): string { - return empty($this->createNamespace) - ? $this->aliases->get($this->createPath) - : $this->getNamespacePath($this->createNamespace); + return empty($this->newMigrationNamespace) + ? $this->aliases->get($this->newMigrationPath) + : $this->getNamespacePath($this->newMigrationNamespace); } /** diff --git a/tests/Common/Command/AbstractCreateCommandTest.php b/tests/Common/Command/AbstractCreateCommandTest.php index b306a5d9..7d90de1d 100644 --- a/tests/Common/Command/AbstractCreateCommandTest.php +++ b/tests/Common/Command/AbstractCreateCommandTest.php @@ -31,7 +31,7 @@ public function testCreateTableWithPath(): void $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', '--command' => 'table']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); @@ -81,7 +81,7 @@ public function testCreateTableWithNamespace(): void $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', '--command' => 'table']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -151,7 +151,7 @@ public function testCreateTableExtends(): void 'category_id:integer:foreignKey,' . 'category_id2:integer:foreignKey(category id2)', ]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -340,7 +340,7 @@ public function testWithoutTablePrefix(): void '--fields' => 'name:string,user_id:integer:foreignKey', ] ); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -425,7 +425,7 @@ public function testExecuteInputNamespaces(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', $option => MigrationHelper::NAMESPACE]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -474,11 +474,11 @@ public function testExecuteInputPath(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', '--path' => MigrationHelper::PATH_ALIAS]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Create new migration y/n:', $output); - $this->assertMatchesRegularExpression("/^\s+M\d{12}Post$/m", $output); + $this->assertMatchesRegularExpression("/\s+M\d{12}Post/m", $output); $this->assertStringContainsString('[OK] New migration created successfully.', $output); $this->assertCount(1, FileHelper::findFiles($path)); } @@ -491,7 +491,7 @@ public function testExecuteNameException(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post?']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsStringCollapsingSpaces( @@ -508,7 +508,7 @@ public function testExecuteCommandException(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', '--command' => 'noExist']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsStringCollapsingSpaces( @@ -528,7 +528,7 @@ public function testExecuteNameToLongException(): void $exitCode = $command->execute([ 'name' => str_repeat('x', 200), ]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('The migration name is too long.', $output); @@ -542,7 +542,7 @@ public function testAddColumn(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post', '--command' => 'addColumn', '--fields' => 'position:integer']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -593,7 +593,7 @@ public function testDropColumn(): void '--command' => 'dropColumn', '--fields' => 'position:integer', ]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -646,7 +646,7 @@ public function testDropTable(): void '--fields' => 'title:string(12):notNull:unique,body:text', ] ); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -703,7 +703,7 @@ public function testCreateTableWithFields(): void '--fields' => 'title:string,body:text', ] ); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -762,7 +762,7 @@ public function testCreateTableWithFieldsForeignKey(): void 'category_id:integer:defaultValue(1):foreignKey,title:string,body:text', ] ); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -885,7 +885,7 @@ public function testJunction(): void '--fields' => 'created_at:dateTime', ] ); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $className = MigrationHelper::findMigrationClassNameInOutput($output); $namespace = MigrationHelper::NAMESPACE; @@ -992,78 +992,78 @@ public function down(MigrationBuilder \$b): void $this->assertEqualsWithoutLE($expectedMigrationCode, $generatedMigrationCode); } - public function testIncorrectCreatePath(): void + public function testIncorrectNewMigrationPath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->setCreatePath(__DIR__ . '/not-exists'); + $this->container->get(MigrationService::class)->setNewMigrationPath(__DIR__ . '/not-exists'); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('Invalid path directory', $output); } - public function testWithoutCreatePath(): void + public function testWithoutNewMigrationPath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->setCreatePath(''); + $this->container->get(MigrationService::class)->setNewMigrationPath(''); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString( - 'One of `createNamespace` or `createPath` should be specified.', + 'One of `newMigrationNamespace` or `newMigrationPath` should be specified.', $output ); } - public function testIncorrectCreateNamespace(): void + public function testIncorrectNewMigrationNamespace(): void { MigrationHelper::useMigrationsNamespace($this->container); $this->container->get(MigrationService::class) - ->setCreateNamespace('Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists'); + ->setNewMigrationNamespace('Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists'); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('Invalid path directory', $output); } - public function testWithoutCreateNamespace(): void + public function testWithoutNewMigrationNamespace(): void { MigrationHelper::useMigrationsNamespace($this->container); - $this->container->get(MigrationService::class)->setCreateNamespace(''); + $this->container->get(MigrationService::class)->setNewMigrationNamespace(''); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString( - 'One of `createNamespace` or `createPath` should be specified.', + 'One of `newMigrationNamespace` or `newMigrationPath` should be specified.', $output ); } - public function testWithCreatePathAndNamespace(): void + public function testWithNewMigrationPathAndNamespace(): void { MigrationHelper::useMigrationsPath($this->container); MigrationHelper::useMigrationsNamespace($this->container); @@ -1072,11 +1072,11 @@ public function testWithCreatePathAndNamespace(): void $command->setInputs(['yes']); $exitCode = $command->execute(['name' => 'post']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString( - 'Only one of `createNamespace` or `createPath` should be specified.', + 'Only one of `newMigrationNamespace` or `newMigrationPath` should be specified.', $output ); } @@ -1091,11 +1091,11 @@ public function testWithOptionsPathAndNamespace(): void '--path' => MigrationHelper::PATH_ALIAS, '--namespace' => MigrationHelper::NAMESPACE, ]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString( - 'Only one of `createNamespace` or `createPath` should be specified.', + 'Only one of `newMigrationNamespace` or `newMigrationPath` should be specified.', $output ); } diff --git a/tests/Common/Command/AbstractDownCommandTest.php b/tests/Common/Command/AbstractDownCommandTest.php index 2fffbd27..f6e49f2c 100644 --- a/tests/Common/Command/AbstractDownCommandTest.php +++ b/tests/Common/Command/AbstractDownCommandTest.php @@ -53,7 +53,7 @@ public function testExecuteWithNamespace(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('1 migration was reverted.', $output); @@ -84,7 +84,7 @@ public function testExecuteWithPath(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('1 migration was reverted.', $output); @@ -146,7 +146,7 @@ public function testDowngradeAll(): void $command->setInputs(['yes']); $exitCode = $command->execute(['--all' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('2 migrations were reverted.', $output); @@ -251,7 +251,7 @@ public function testLimit(): void $command->setInputs(['yes']); $exitCode = $command->execute(['-l' => '2']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString("1. $createUserClass", $output); @@ -277,7 +277,7 @@ public function testIncorrectLimit(int $limit): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['--limit' => $limit]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('The limit option must be greater than 0.', $output); @@ -311,7 +311,7 @@ public function testPartiallyReverted(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 1 out of 2 migrations were reverted.', $output); @@ -339,7 +339,7 @@ public function testNotReverted(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 0 out of 1 migration was reverted.', $output); @@ -372,7 +372,7 @@ public function testOptionsNamespaceAndPath(): void foreach ($options as $option => $value) { $exitCode = $command->setInputs(['no'])->execute([$option => $value, '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 migration to be reverted:', $output); @@ -404,7 +404,7 @@ public function testOptionsNamespaceAndPathWithoutMigrations(): void foreach ($options as $option => $value) { $exitCode = $command->execute([$option => $value]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::FAILURE, $exitCode); $this->assertStringContainsString('[WARNING] No applied migrations found.', $output); @@ -440,7 +440,7 @@ public function testOptionsNamespaceWithDifferentPaths(): void foreach ($options as $option => $value) { $exitCode = $command->setInputs(['no'])->execute([$option => $value, '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 2 migrations to be reverted:', $output); @@ -474,7 +474,7 @@ public function testOptionsPathForNamespaceWithDifferentPaths(): void $path = dirname(__DIR__, 2) . '/Support/MigrationsExtra'; $exitCode = $command->setInputs(['no'])->execute(['--path' => [$path], '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 migration to be reverted:', $output); diff --git a/tests/Common/Command/AbstractHistoryCommandTest.php b/tests/Common/Command/AbstractHistoryCommandTest.php index a863b138..24d7176f 100644 --- a/tests/Common/Command/AbstractHistoryCommandTest.php +++ b/tests/Common/Command/AbstractHistoryCommandTest.php @@ -38,7 +38,7 @@ public function testExecute(): void $command = $this->createCommand($this->container); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertEquals(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 2 migrations have been applied before:', $output); @@ -68,7 +68,7 @@ public function testLimit(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['-l' => '1']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Last 1 applied migration:', $output); @@ -90,7 +90,7 @@ public function testIncorrectLimit(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['-l' => -1]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('The limit option must be greater than 0.', $output); @@ -103,7 +103,7 @@ public function testWithoutNewMigrations(): void $command = $this->createCommand($this->container); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::FAILURE, $exitCode); $this->assertStringContainsString('[WARNING] No migration has been done before.', $output); @@ -131,7 +131,7 @@ public function testOptionAll(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['--all' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 2 migrations have been applied before:', $output); diff --git a/tests/Common/Command/AbstractNewCommandTest.php b/tests/Common/Command/AbstractNewCommandTest.php index 1cb9a3fe..12cb9905 100644 --- a/tests/Common/Command/AbstractNewCommandTest.php +++ b/tests/Common/Command/AbstractNewCommandTest.php @@ -47,7 +47,7 @@ public function testExecuteWithNamespace(): void $command = $this->createCommand($this->container); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Found 2 new migrations:', $output); @@ -87,7 +87,7 @@ public function testExecuteWithPath(): void $command = $this->createCommand($this->container); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Found 2 new migrations:', $output); @@ -100,7 +100,7 @@ public function testIncorrectLimit(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['-l' => -1]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('[ERROR] The limit option must be greater than 0.', $output); @@ -122,7 +122,7 @@ public function testWithoutNewMigrations(): void $command = $this->createCommand($this->container); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::FAILURE, $exitCode); $this->assertStringContainsString('[WARNING] No new migrations found. Your system is up-to-date', $output); @@ -160,7 +160,7 @@ public function testCountMigrationsMoreLimit(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['--limit' => 2]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('[WARNING] Showing 2 out of 3 new migrations:', $output); @@ -190,7 +190,7 @@ public function testOptionAll(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['--all' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Found 2 new migrations:', $output); @@ -211,7 +211,7 @@ public function testOptionPath(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['--path' => [MigrationHelper::PATH_ALIAS]]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Found 1 new migration:', $output); @@ -233,7 +233,7 @@ public function testOptionNamespace(): void $command = $this->createCommand($this->container); foreach (['--namespace', '-ns'] as $option) { $exitCode = $command->execute([$option => [MigrationHelper::NAMESPACE]]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Found 1 new migration:', $output); diff --git a/tests/Common/Command/AbstractRedoCommandTest.php b/tests/Common/Command/AbstractRedoCommandTest.php index 14253196..c2107e5d 100644 --- a/tests/Common/Command/AbstractRedoCommandTest.php +++ b/tests/Common/Command/AbstractRedoCommandTest.php @@ -52,7 +52,7 @@ public function testExecuteWithNamespace(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('1 migration was redone.', $output); @@ -83,7 +83,7 @@ public function testExecuteWithPath(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('1 migration was redone.', $output); @@ -114,7 +114,7 @@ public function testLimit(): void $command->setInputs(['yes']); $exitCode = $command->execute(['-l' => '2']); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString("1. $createUserClass", $output); @@ -148,7 +148,7 @@ public function testIncorrectLimit(): void $command->setInputs(['yes']); $exitCode = $command->execute(['-l' => -1]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('The limit option must be greater than 0.', $output); @@ -162,7 +162,7 @@ public function testWithoutNewMigrations(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::FAILURE, $exitCode); $this->assertStringContainsString('[WARNING] No migration has been done before.', $output); @@ -206,7 +206,7 @@ public function testOptionAll(): void $command = $this->createCommand($this->container); $exitCode = $command->setInputs(['no'])->execute(['--all' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 2 migrations to be redone:', $output); @@ -240,7 +240,7 @@ public function testPartiallyReverted(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 1 out of 2 migrations were reverted.', $output); @@ -268,7 +268,7 @@ public function testNotReverted(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 0 out of 1 migration was reverted.', $output); @@ -296,7 +296,7 @@ public function testRevertedButPartiallyApplied(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 1 out of 2 migrations were applied.', $output); @@ -319,7 +319,7 @@ public function testRevertedButNotApplied(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 0 out of 1 migration was applied.', $output); @@ -355,7 +355,7 @@ public function testOptionsNamespaceAndPath(): void foreach ($options as $option => $value) { $exitCode = $command->setInputs(['no'])->execute([$option => $value, '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 migration to be redone:', $output); @@ -387,7 +387,7 @@ public function testOptionsNamespaceAndPathWithoutMigrations(): void foreach ($options as $option => $value) { $exitCode = $command->execute([$option => $value]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::FAILURE, $exitCode); $this->assertStringContainsString('[WARNING] No applied migrations found.', $output); @@ -423,7 +423,7 @@ public function testOptionsNamespaceWithDifferentPaths(): void foreach ($options as $option => $value) { $exitCode = $command->setInputs(['no'])->execute([$option => $value, '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 2 migrations to be redone:', $output); @@ -457,7 +457,7 @@ public function testOptionsPathForNamespaceWithDifferentPaths(): void $path = dirname(__DIR__, 2) . '/Support/MigrationsExtra'; $exitCode = $command->setInputs(['no'])->execute(['--path' => [$path], '-a' => true]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 migration to be redone:', $output); diff --git a/tests/Common/Command/AbstractUpdateCommandTest.php b/tests/Common/Command/AbstractUpdateCommandTest.php index 7be3a0c8..b21bcbc4 100644 --- a/tests/Common/Command/AbstractUpdateCommandTest.php +++ b/tests/Common/Command/AbstractUpdateCommandTest.php @@ -42,7 +42,7 @@ public function testExecuteWithPath(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $db = $this->container->get(ConnectionInterface::class); $dbSchema = $db->getSchema(); @@ -150,7 +150,7 @@ public function testExecuteExtended(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $dbSchema = $db->getSchema(); $departmentSchema = $dbSchema->getTableSchema('department'); @@ -220,13 +220,13 @@ public function testExecuteAgain(): void $command1->setInputs(['yes']); $exitCode1 = $command1->execute([]); - $output1 = $command1->getDisplay(true); + $output1 = preg_replace('/(\R|\s)+/', ' ', $command1->getDisplay(true)); $command2 = $this->createCommand($this->container); $command2->setInputs(['yes']); $exitCode2 = $command2->execute([]); - $output2 = $command2->getDisplay(true); + $output2 = preg_replace('/(\R|\s)+/', ' ', $command2->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode1); $this->assertStringContainsString('Total 1 new migration was applied.', $output1); @@ -261,40 +261,40 @@ public function testNotMigrationInterface(): void $command->execute([]); } - public function testWithoutUpdatePath(): void + public function testWithoutSourcePath(): void { MigrationHelper::useMigrationsPath($this->container); - $this->container->get(MigrationService::class)->setUpdatePaths([]); + $this->container->get(MigrationService::class)->setSourcePaths([]); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsStringCollapsingSpaces( - 'At least one of `updateNamespaces` or `updatePaths` should be specified.', + 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.', $output ); } - public function testWithoutUpdateNamespaces(): void + public function testWithoutSourceNamespaces(): void { MigrationHelper::useMigrationsNamespace($this->container); - $this->container->get(MigrationService::class)->setUpdateNamespaces([]); + $this->container->get(MigrationService::class)->setSourceNamespaces([]); $command = $this->createCommand($this->container); $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsStringCollapsingSpaces( - 'At least one of `updateNamespaces` or `updatePaths` should be specified.', + 'At least one of `sourceNamespaces` or `sourcePaths` should be specified.', $output ); } @@ -323,7 +323,7 @@ public function testLimit(): void $command->setInputs(['yes']); $exitCode = $command->execute(['-l' => 1]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 out of 2 new migrations to be applied:', $output); @@ -348,7 +348,7 @@ public function testNameLimit(): void $command->setInputs(['yes']); $exitCode = $command->execute([]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString( @@ -372,7 +372,7 @@ public function testOptionPath(): void $command = $this->createCommand($this->container); $exitCode = $command->setInputs(['no'])->execute(['--path' => [MigrationHelper::PATH_ALIAS]]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 new migration to be applied:', $output); @@ -395,7 +395,7 @@ public function testOptionNamespace(): void foreach (['--namespace', '-ns'] as $option) { $exitCode = $command->setInputs(['no'])->execute([$option => [MigrationHelper::NAMESPACE]]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::SUCCESS, $exitCode); $this->assertStringContainsString('Total 1 new migration to be applied:', $output); @@ -410,7 +410,7 @@ public function testIncorrectLimit(): void $command = $this->createCommand($this->container); $exitCode = $command->execute(['-l' => -1]); - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertSame(Command::INVALID, $exitCode); $this->assertStringContainsString('[ERROR] The limit option must be greater than 0.', $output); @@ -441,7 +441,7 @@ public function testPartiallyUpdated(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 1 out of 2 new migrations were applied.', $output); @@ -475,7 +475,7 @@ public function testNotUpdated(): void } catch (Throwable) { } - $output = $command->getDisplay(true); + $output = preg_replace('/(\R|\s)+/', ' ', $command->getDisplay(true)); $this->assertFalse(isset($exitCode)); $this->assertStringContainsString('>>> Total 0 out of 1 new migration was applied.', $output); diff --git a/tests/Common/Service/AbstractMigrationServiceTest.php b/tests/Common/Service/AbstractMigrationServiceTest.php index e0472d94..f2cc9154 100644 --- a/tests/Common/Service/AbstractMigrationServiceTest.php +++ b/tests/Common/Service/AbstractMigrationServiceTest.php @@ -46,7 +46,7 @@ public function testGetNewMigrationsWithNotExistNamespace(): void $service = $this->container->get(MigrationService::class); - $service->setUpdateNamespaces([ + $service->setSourceNamespaces([ MigrationHelper::NAMESPACE, 'Yiisoft\\Db\\Migration\\TestsRuntime\\NotExists', ]); diff --git a/tests/Support/Helper/MigrationHelper.php b/tests/Support/Helper/MigrationHelper.php index a29ae50b..ba153c2f 100644 --- a/tests/Support/Helper/MigrationHelper.php +++ b/tests/Support/Helper/MigrationHelper.php @@ -26,8 +26,8 @@ public static function useMigrationsPath(ContainerInterface $container): string { $service = $container->get(MigrationService::class); - $service->setCreatePath(self::PATH_ALIAS); - $service->setUpdatePaths([self::PATH_ALIAS]); + $service->setNewMigrationPath(self::PATH_ALIAS); + $service->setSourcePaths([self::PATH_ALIAS]); self::preparePaths($container); @@ -41,8 +41,8 @@ public static function useMigrationsNamespace(ContainerInterface $container): st { $service = $container->get(MigrationService::class); - $service->setCreateNamespace(self::NAMESPACE); - $service->setUpdateNamespaces([self::NAMESPACE]); + $service->setNewMigrationNamespace(self::NAMESPACE); + $service->setSourceNamespaces([self::NAMESPACE]); self::preparePaths($container); @@ -67,7 +67,7 @@ public static function createMigration( $createService = $container->get(CreateService::class); $aliases = $container->get(Aliases::class); - $namespace = $migrationService->getCreateNamespace(); + $namespace = $migrationService->getNewMigrationNamespace(); $className = $migrationService->generateClassName($name); $content = $createService->run( @@ -136,9 +136,9 @@ public static function resetPathAndNamespace(ContainerInterface $container): voi { $service = $container->get(MigrationService::class); - $service->setCreatePath(''); - $service->setUpdatePaths([]); - $service->setCreateNamespace(''); - $service->setUpdateNamespaces([]); + $service->setNewMigrationPath(''); + $service->setSourcePaths([]); + $service->setNewMigrationNamespace(''); + $service->setSourceNamespaces([]); } }