Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Dec 21, 2023
1 parent 6b4e0fa commit 3cc5faa
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 71 deletions.
40 changes: 20 additions & 20 deletions tests/Common/Command/AbstractCreateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -474,7 +474,7 @@ 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);
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ public function testIncorrectCreatePath(): 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('Invalid path directory', $output);
Expand All @@ -1018,7 +1018,7 @@ public function testWithoutCreatePath(): 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(
Expand All @@ -1038,7 +1038,7 @@ public function testIncorrectNewMigrationNamespace(): 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('Invalid path directory', $output);
Expand Down Expand Up @@ -1072,7 +1072,7 @@ 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(
Expand All @@ -1091,7 +1091,7 @@ 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(
Expand Down
22 changes: 11 additions & 11 deletions tests/Common/Command/AbstractDownCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions tests/Common/Command/AbstractHistoryCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions tests/Common/Command/AbstractNewCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 3cc5faa

Please sign in to comment.