aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-04-11 19:37:29 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-04-11 19:37:29 +0200
commit637dc4bb21edf8f3b0b0926aa50fa5ffdf362db8 (patch)
treedf86ecf2e2faf6340094ce23945d72813469f55c /src/Wallabag
parenta83fbf4504f08612020792bd454bf1c881fb3c14 (diff)
downloadwallabag-637dc4bb21edf8f3b0b0926aa50fa5ffdf362db8.tar.gz
wallabag-637dc4bb21edf8f3b0b0926aa50fa5ffdf362db8.tar.zst
wallabag-637dc4bb21edf8f3b0b0926aa50fa5ffdf362db8.zip
Move setup config outside setupAdmin
If user doesn't want to create a new admin (even if it's recommended) the internal config weren't created resulting in error when using the interface.
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php19
-rw-r--r--src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php54
2 files changed, 45 insertions, 28 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 2e4a59df..e56ee4af 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -60,6 +60,7 @@ class InstallCommand extends ContainerAwareCommand
60 ->checkRequirements() 60 ->checkRequirements()
61 ->setupDatabase() 61 ->setupDatabase()
62 ->setupAdmin() 62 ->setupAdmin()
63 ->setupConfig()
63 ->setupAsset() 64 ->setupAsset()
64 ; 65 ;
65 66
@@ -69,7 +70,7 @@ class InstallCommand extends ContainerAwareCommand
69 70
70 protected function checkRequirements() 71 protected function checkRequirements()
71 { 72 {
72 $this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>'); 73 $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>');
73 74
74 $fulfilled = true; 75 $fulfilled = true;
75 76
@@ -119,7 +120,7 @@ class InstallCommand extends ContainerAwareCommand
119 120
120 protected function setupDatabase() 121 protected function setupDatabase()
121 { 122 {
122 $this->defaultOutput->writeln('<info><comment>Step 2 of 4.</comment> Setting up database.</info>'); 123 $this->defaultOutput->writeln('<info><comment>Step 2 of 5.</comment> Setting up database.</info>');
123 124
124 // user want to reset everything? Don't care about what is already here 125 // user want to reset everything? Don't care about what is already here
125 if (true === $this->defaultInput->getOption('reset')) { 126 if (true === $this->defaultInput->getOption('reset')) {
@@ -190,7 +191,7 @@ class InstallCommand extends ContainerAwareCommand
190 191
191 protected function setupAdmin() 192 protected function setupAdmin()
192 { 193 {
193 $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>'); 194 $this->defaultOutput->writeln('<info><comment>Step 3 of 5.</comment> Administration setup.</info>');
194 195
195 $questionHelper = $this->getHelperSet()->get('question'); 196 $questionHelper = $this->getHelperSet()->get('question');
196 $question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true); 197 $question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true);
@@ -227,6 +228,16 @@ class InstallCommand extends ContainerAwareCommand
227 228
228 $em->persist($config); 229 $em->persist($config);
229 230
231 $this->defaultOutput->writeln('');
232
233 return $this;
234 }
235
236 protected function setupConfig()
237 {
238 $this->defaultOutput->writeln('<info><comment>Step 4 of 5.</comment> Config setup.</info>');
239 $em = $this->getContainer()->get('doctrine.orm.entity_manager');
240
230 // cleanup before insert new stuff 241 // cleanup before insert new stuff
231 $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute(); 242 $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute();
232 243
@@ -365,7 +376,7 @@ class InstallCommand extends ContainerAwareCommand
365 376
366 protected function setupAsset() 377 protected function setupAsset()
367 { 378 {
368 $this->defaultOutput->writeln('<info><comment>Step 4 of 4.</comment> Installing assets.</info>'); 379 $this->defaultOutput->writeln('<info><comment>Step 5 of 5.</comment> Installing assets.</info>');
369 380
370 $this 381 $this
371 ->runCommand('assets:install') 382 ->runCommand('assets:install')
diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
index bb8fb888..bd61f750 100644
--- a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php
@@ -67,10 +67,11 @@ class InstallCommandTest extends WallabagCoreTestCase
67 'command' => $command->getName(), 67 'command' => $command->getName(),
68 )); 68 ));
69 69
70 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 70 $this->assertContains('Checking system requirements.', $tester->getDisplay());
71 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 71 $this->assertContains('Setting up database.', $tester->getDisplay());
72 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 72 $this->assertContains('Administration setup.', $tester->getDisplay());
73 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 73 $this->assertContains('Config setup.', $tester->getDisplay());
74 $this->assertContains('Installing assets.', $tester->getDisplay());
74 } 75 }
75 76
76 public function testRunInstallCommandWithReset() 77 public function testRunInstallCommandWithReset()
@@ -97,11 +98,12 @@ class InstallCommandTest extends WallabagCoreTestCase
97 '--reset' => true, 98 '--reset' => true,
98 )); 99 ));
99 100
100 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 101 $this->assertContains('Checking system requirements.', $tester->getDisplay());
101 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 102 $this->assertContains('Setting up database.', $tester->getDisplay());
102 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); 103 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
103 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 104 $this->assertContains('Administration setup.', $tester->getDisplay());
104 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 105 $this->assertContains('Config setup.', $tester->getDisplay());
106 $this->assertContains('Installing assets.', $tester->getDisplay());
105 107
106 // we force to reset everything 108 // we force to reset everything
107 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); 109 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
@@ -142,10 +144,11 @@ class InstallCommandTest extends WallabagCoreTestCase
142 'command' => $command->getName(), 144 'command' => $command->getName(),
143 )); 145 ));
144 146
145 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 147 $this->assertContains('Checking system requirements.', $tester->getDisplay());
146 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 148 $this->assertContains('Setting up database.', $tester->getDisplay());
147 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 149 $this->assertContains('Administration setup.', $tester->getDisplay());
148 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 150 $this->assertContains('Config setup.', $tester->getDisplay());
151 $this->assertContains('Installing assets.', $tester->getDisplay());
149 152
150 // the current database doesn't already exist 153 // the current database doesn't already exist
151 $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); 154 $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
@@ -179,10 +182,11 @@ class InstallCommandTest extends WallabagCoreTestCase
179 'command' => $command->getName(), 182 'command' => $command->getName(),
180 )); 183 ));
181 184
182 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 185 $this->assertContains('Checking system requirements.', $tester->getDisplay());
183 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 186 $this->assertContains('Setting up database.', $tester->getDisplay());
184 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 187 $this->assertContains('Administration setup.', $tester->getDisplay());
185 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 188 $this->assertContains('Config setup.', $tester->getDisplay());
189 $this->assertContains('Installing assets.', $tester->getDisplay());
186 190
187 $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); 191 $this->assertContains('Droping schema and creating schema', $tester->getDisplay());
188 } 192 }
@@ -233,10 +237,11 @@ class InstallCommandTest extends WallabagCoreTestCase
233 'command' => $command->getName(), 237 'command' => $command->getName(),
234 )); 238 ));
235 239
236 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 240 $this->assertContains('Checking system requirements.', $tester->getDisplay());
237 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 241 $this->assertContains('Setting up database.', $tester->getDisplay());
238 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 242 $this->assertContains('Administration setup.', $tester->getDisplay());
239 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 243 $this->assertContains('Config setup.', $tester->getDisplay());
244 $this->assertContains('Installing assets.', $tester->getDisplay());
240 245
241 $this->assertContains('Creating schema', $tester->getDisplay()); 246 $this->assertContains('Creating schema', $tester->getDisplay());
242 } 247 }
@@ -265,9 +270,10 @@ class InstallCommandTest extends WallabagCoreTestCase
265 '--no-interaction' => true, 270 '--no-interaction' => true,
266 )); 271 ));
267 272
268 $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); 273 $this->assertContains('Checking system requirements.', $tester->getDisplay());
269 $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); 274 $this->assertContains('Setting up database.', $tester->getDisplay());
270 $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); 275 $this->assertContains('Administration setup.', $tester->getDisplay());
271 $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); 276 $this->assertContains('Config setup.', $tester->getDisplay());
277 $this->assertContains('Installing assets.', $tester->getDisplay());
272 } 278 }
273} 279}