Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename atlas:dump-sql cmd to atlas:schema #26

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
CREATE TABLE bugs (id INT AUTO_INCREMENT NOT NULL, description VARCHAR(255) NOT NULL, created DATETIME NOT NULL, status VARCHAR(255) NOT NULL, engineer_id INT DEFAULT NULL, reporter_id INT DEFAULT NULL, INDEX IDX_1E197C9F8D8CDF1 (engineer_id), INDEX IDX_1E197C9E1CFE6F5 (reporter_id), PRIMARY KEY(id));
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
Loading