Skip to content

Commit

Permalink
rename atlas:dump-sql cmd to atlas:schema (#26) (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenlu authored Mar 27, 2024
1 parent 29327e6 commit 48a880d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data "external_schema" "doctrine" {
program = [
"php",
"bin/doctrine", // path to your Doctrine Console file
"atlas:dump-sql",
"atlas:schema",
"--path", "./path/to/entities",
"--dialect", "mysql" // mariadb | postgres | sqlite | sqlserver
]
Expand Down Expand Up @@ -96,7 +96,7 @@ data "external_schema" "doctrine" {
program = [
"php",
"bin/console",
"atlas:dump-sql"
"atlas:schema"
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(Configuration $config = null)
protected function configure(): void
{
$dialects = DialectsMapping::getInstance()->getDialects();
$this->setName('atlas:dump-sql')
$this->setName('atlas:schema')
->addOption(
'dialect',
null,
Expand Down
8 changes: 4 additions & 4 deletions tests/BundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public function testRegisterCommandsNoConfig(): void
$bundle->setContainer($container);
$application = new Application();
$bundle->registerCommands($application);
$this->assertTrue($application->has('atlas:dump-sql'));
$this->assertTrue($application->has('atlas:schema'));

// run the command to check if it works
$command = $application->find('atlas:dump-sql');
$command = $application->find('atlas:schema');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
Expand Down Expand Up @@ -55,10 +55,10 @@ public function testRegisterCommandsWithConfig(): void
$bundle->setContainer($container);
$application = new Application();
$bundle->registerCommands($application);
$this->assertTrue($application->has('atlas:dump-sql'));
$this->assertTrue($application->has('atlas:schema'));

// run the command to check if it works with the underscore naming strategy
$command = $application->find('atlas:dump-sql');
$command = $application->find('atlas:schema');
$commandTester = new CommandTester($command);
$commandTester->execute([
'command' => $command->getName(),
Expand Down
6 changes: 3 additions & 3 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class CommandTest extends TestCase

public function testCommand(): void
{
$output = shell_exec("php tests/bin/doctrine atlas:dump-sql --dialect mysql --path ./tests/entities/regular");
$output = shell_exec("php tests/bin/doctrine atlas:schema --dialect mysql --path ./tests/entities/regular");
$expected = 'CREATE TABLE users (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
CREATE TABLE bugs (id INT AUTO_INCREMENT NOT NULL, engineer_id INT DEFAULT NULL, reporter_id INT DEFAULT NULL, description VARCHAR(255) NOT NULL, created DATETIME NOT NULL, status VARCHAR(255) NOT NULL, INDEX IDX_1E197C9F8D8CDF1 (engineer_id), INDEX IDX_1E197C9E1CFE6F5 (reporter_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB;
ALTER TABLE bugs ADD CONSTRAINT FK_1E197C9F8D8CDF1 FOREIGN KEY (engineer_id) REFERENCES users (id);
Expand All @@ -20,15 +20,15 @@ public function testCommand(): void

public function testCommandInvalidDialect(): void
{
exec("php tests/bin/doctrine atlas:dump-sql --dialect bad_dialect --path ./tests/entities/regular", $output, $return_var);
exec("php tests/bin/doctrine atlas:schema --dialect bad_dialect --path ./tests/entities/regular", $output, $return_var);
$this->assertEquals(1, $return_var);
// check that stderr contains the expected error message
$this->assertStringContainsString("Invalid dialect: bad_dialect", $output[1]);
}

public function testCommandInvalidPath(): void
{
exec("php tests/bin/doctrine atlas:dump-sql --dialect mysql --path /bad/path", $output, $return_var);
exec("php tests/bin/doctrine atlas:schema --dialect mysql --path /bad/path", $output, $return_var);
$this->assertEquals(1, $return_var);
$this->assertStringContainsString("Invalid path: /bad/path", $output[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/atlas.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data "external_schema" "doctrine" {
program = [
"php",
"tests/bin/doctrine",
"atlas:dump-sql",
"atlas:schema",
"--path", "tests/entities/regular",
"--dialect", var.dialect,
]
Expand Down

0 comments on commit 48a880d

Please sign in to comment.