diff options
3 files changed, 26 insertions, 12 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 3c4d3f25..0d9364f6 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -63,6 +63,7 @@ class InstallCommand extends ContainerAwareCommand | |||
63 | ->setupDatabase() | 63 | ->setupDatabase() |
64 | ->setupAdmin() | 64 | ->setupAdmin() |
65 | ->setupConfig() | 65 | ->setupConfig() |
66 | ->runMigrations() | ||
66 | ; | 67 | ; |
67 | 68 | ||
68 | $output->writeln('<info>wallabag has been successfully installed.</info>'); | 69 | $output->writeln('<info>wallabag has been successfully installed.</info>'); |
@@ -71,7 +72,7 @@ class InstallCommand extends ContainerAwareCommand | |||
71 | 72 | ||
72 | protected function checkRequirements() | 73 | protected function checkRequirements() |
73 | { | 74 | { |
74 | $this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>'); | 75 | $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>'); |
75 | $doctrineManager = $this->getContainer()->get('doctrine')->getManager(); | 76 | $doctrineManager = $this->getContainer()->get('doctrine')->getManager(); |
76 | 77 | ||
77 | $rows = []; | 78 | $rows = []; |
@@ -175,11 +176,11 @@ class InstallCommand extends ContainerAwareCommand | |||
175 | 176 | ||
176 | protected function setupDatabase() | 177 | protected function setupDatabase() |
177 | { | 178 | { |
178 | $this->defaultOutput->writeln('<info><comment>Step 2 of 4.</comment> Setting up database.</info>'); | 179 | $this->defaultOutput->writeln('<info><comment>Step 2 of 5.</comment> Setting up database.</info>'); |
179 | 180 | ||
180 | // user want to reset everything? Don't care about what is already here | 181 | // user want to reset everything? Don't care about what is already here |
181 | if (true === $this->defaultInput->getOption('reset')) { | 182 | if (true === $this->defaultInput->getOption('reset')) { |
182 | $this->defaultOutput->writeln('Droping database, creating database and schema, clearing the cache'); | 183 | $this->defaultOutput->writeln('Dropping database, creating database and schema, clearing the cache'); |
183 | 184 | ||
184 | $this | 185 | $this |
185 | ->runCommand('doctrine:database:drop', ['--force' => true]) | 186 | ->runCommand('doctrine:database:drop', ['--force' => true]) |
@@ -211,7 +212,7 @@ class InstallCommand extends ContainerAwareCommand | |||
211 | $question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false); | 212 | $question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false); |
212 | 213 | ||
213 | if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) { | 214 | if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) { |
214 | $this->defaultOutput->writeln('Droping database, creating database and schema'); | 215 | $this->defaultOutput->writeln('Dropping database, creating database and schema'); |
215 | 216 | ||
216 | $this | 217 | $this |
217 | ->runCommand('doctrine:database:drop', ['--force' => true]) | 218 | ->runCommand('doctrine:database:drop', ['--force' => true]) |
@@ -221,7 +222,7 @@ class InstallCommand extends ContainerAwareCommand | |||
221 | } elseif ($this->isSchemaPresent()) { | 222 | } elseif ($this->isSchemaPresent()) { |
222 | $question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false); | 223 | $question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false); |
223 | if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) { | 224 | if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) { |
224 | $this->defaultOutput->writeln('Droping schema and creating schema'); | 225 | $this->defaultOutput->writeln('Dropping schema and creating schema'); |
225 | 226 | ||
226 | $this | 227 | $this |
227 | ->runCommand('doctrine:schema:drop', ['--force' => true]) | 228 | ->runCommand('doctrine:schema:drop', ['--force' => true]) |
@@ -246,7 +247,7 @@ class InstallCommand extends ContainerAwareCommand | |||
246 | 247 | ||
247 | protected function setupAdmin() | 248 | protected function setupAdmin() |
248 | { | 249 | { |
249 | $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>'); | 250 | $this->defaultOutput->writeln('<info><comment>Step 3 of 5.</comment> Administration setup.</info>'); |
250 | 251 | ||
251 | $questionHelper = $this->getHelperSet()->get('question'); | 252 | $questionHelper = $this->getHelperSet()->get('question'); |
252 | $question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true); | 253 | $question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true); |
@@ -285,7 +286,7 @@ class InstallCommand extends ContainerAwareCommand | |||
285 | 286 | ||
286 | protected function setupConfig() | 287 | protected function setupConfig() |
287 | { | 288 | { |
288 | $this->defaultOutput->writeln('<info><comment>Step 4 of 4.</comment> Config setup.</info>'); | 289 | $this->defaultOutput->writeln('<info><comment>Step 4 of 5.</comment> Config setup.</info>'); |
289 | $em = $this->getContainer()->get('doctrine.orm.entity_manager'); | 290 | $em = $this->getContainer()->get('doctrine.orm.entity_manager'); |
290 | 291 | ||
291 | // cleanup before insert new stuff | 292 | // cleanup before insert new stuff |
@@ -464,6 +465,14 @@ class InstallCommand extends ContainerAwareCommand | |||
464 | return $this; | 465 | return $this; |
465 | } | 466 | } |
466 | 467 | ||
468 | protected function runMigrations() | ||
469 | { | ||
470 | $this->defaultOutput->writeln('<info><comment>Step 5 of 5.</comment> Run migrations.</info>'); | ||
471 | |||
472 | $this | ||
473 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]); | ||
474 | } | ||
475 | |||
467 | /** | 476 | /** |
468 | * Run a command. | 477 | * Run a command. |
469 | * | 478 | * |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index f0173cef..362c269b 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -766,10 +766,9 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
766 | ], | 766 | ], |
767 | ]; | 767 | ]; |
768 | 768 | ||
769 | $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list)); | 769 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); |
770 | } | 770 | } |
771 | 771 | ||
772 | |||
773 | public function testPostEntriesListAction() | 772 | public function testPostEntriesListAction() |
774 | { | 773 | { |
775 | $list = [ | 774 | $list = [ |
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index 1bfd41d5..122a87d4 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | |||
@@ -87,6 +87,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
87 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 87 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
88 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 88 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
89 | $this->assertContains('Config setup.', $tester->getDisplay()); | 89 | $this->assertContains('Config setup.', $tester->getDisplay()); |
90 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | public function testRunInstallCommandWithReset() | 93 | public function testRunInstallCommandWithReset() |
@@ -115,12 +116,13 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
115 | 116 | ||
116 | $this->assertContains('Checking system requirements.', $tester->getDisplay()); | 117 | $this->assertContains('Checking system requirements.', $tester->getDisplay()); |
117 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 118 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
118 | $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 119 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
119 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 120 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
120 | $this->assertContains('Config setup.', $tester->getDisplay()); | 121 | $this->assertContains('Config setup.', $tester->getDisplay()); |
122 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
121 | 123 | ||
122 | // we force to reset everything | 124 | // we force to reset everything |
123 | $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); | 125 | $this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay()); |
124 | } | 126 | } |
125 | 127 | ||
126 | public function testRunInstallCommandWithDatabaseRemoved() | 128 | public function testRunInstallCommandWithDatabaseRemoved() |
@@ -168,6 +170,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
168 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 170 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
169 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 171 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
170 | $this->assertContains('Config setup.', $tester->getDisplay()); | 172 | $this->assertContains('Config setup.', $tester->getDisplay()); |
173 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
171 | 174 | ||
172 | // the current database doesn't already exist | 175 | // the current database doesn't already exist |
173 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); | 176 | $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); |
@@ -205,8 +208,9 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
205 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 208 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
206 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 209 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
207 | $this->assertContains('Config setup.', $tester->getDisplay()); | 210 | $this->assertContains('Config setup.', $tester->getDisplay()); |
211 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
208 | 212 | ||
209 | $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); | 213 | $this->assertContains('Dropping schema and creating schema', $tester->getDisplay()); |
210 | } | 214 | } |
211 | 215 | ||
212 | public function testRunInstallCommandChooseNothing() | 216 | public function testRunInstallCommandChooseNothing() |
@@ -259,6 +263,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
259 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 263 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
260 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 264 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
261 | $this->assertContains('Config setup.', $tester->getDisplay()); | 265 | $this->assertContains('Config setup.', $tester->getDisplay()); |
266 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
262 | 267 | ||
263 | $this->assertContains('Creating schema', $tester->getDisplay()); | 268 | $this->assertContains('Creating schema', $tester->getDisplay()); |
264 | } | 269 | } |
@@ -291,5 +296,6 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
291 | $this->assertContains('Setting up database.', $tester->getDisplay()); | 296 | $this->assertContains('Setting up database.', $tester->getDisplay()); |
292 | $this->assertContains('Administration setup.', $tester->getDisplay()); | 297 | $this->assertContains('Administration setup.', $tester->getDisplay()); |
293 | $this->assertContains('Config setup.', $tester->getDisplay()); | 298 | $this->assertContains('Config setup.', $tester->getDisplay()); |
299 | $this->assertContains('Run migrations.', $tester->getDisplay()); | ||
294 | } | 300 | } |
295 | } | 301 | } |