| @@ 19-40 (lines=22) @@ | ||
| 16 | @unlink(sys_get_temp_dir() . '/shard_2'); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function testExecute() |
|
| 20 | { |
|
| 21 | $connectionName = 'default'; |
|
| 22 | $dbName = 'test'; |
|
| 23 | $params = [ |
|
| 24 | 'path' => sys_get_temp_dir() . '/' . $dbName, |
|
| 25 | 'driver' => 'pdo_sqlite', |
|
| 26 | ]; |
|
| 27 | ||
| 28 | $application = new Application(); |
|
| 29 | $application->add(new CreateDatabaseDoctrineCommand()); |
|
| 30 | ||
| 31 | $command = $application->find('doctrine:database:create'); |
|
| 32 | $command->setContainer($this->getMockContainer($connectionName, $params)); |
|
| 33 | ||
| 34 | $commandTester = new CommandTester($command); |
|
| 35 | $commandTester->execute( |
|
| 36 | array_merge(['command' => $command->getName()]) |
|
| 37 | ); |
|
| 38 | ||
| 39 | $this->assertContains('Created database ' . sys_get_temp_dir() . '/' . $dbName . ' for connection named ' . $connectionName, $commandTester->getDisplay()); |
|
| 40 | } |
|
| 41 | ||
| 42 | public function testExecuteWithShardOption() |
|
| 43 | { |
|
| @@ 64-86 (lines=23) @@ | ||
| 61 | $this->assertContains("Database for connection named `". $dbName ."` doesn't exist. Skipped.", $commandTester->getDisplay()); |
|
| 62 | }*/ |
|
| 63 | ||
| 64 | public function testExecuteWithoutOptionForceWillFailWithAttentionMessage() |
|
| 65 | { |
|
| 66 | $connectionName = 'default'; |
|
| 67 | $dbName = 'test'; |
|
| 68 | $params = array( |
|
| 69 | 'path' => sys_get_temp_dir() . "/" . $dbName, |
|
| 70 | 'driver' => 'pdo_sqlite', |
|
| 71 | ); |
|
| 72 | ||
| 73 | $application = new Application(); |
|
| 74 | $application->add(new DropDatabaseDoctrineCommand()); |
|
| 75 | ||
| 76 | $command = $application->find('doctrine:database:drop'); |
|
| 77 | $command->setContainer($this->getMockContainer($connectionName, $params)); |
|
| 78 | ||
| 79 | $commandTester = new CommandTester($command); |
|
| 80 | $commandTester->execute( |
|
| 81 | array_merge(array('command' => $command->getName())) |
|
| 82 | ); |
|
| 83 | ||
| 84 | $this->assertContains("Would drop the database named " . sys_get_temp_dir() . "/" . $dbName . ".", $commandTester->getDisplay()); |
|
| 85 | $this->assertContains("Please run the operation with --force to execute", $commandTester->getDisplay()); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @param string $connectionName Connection name |
|