]> git.mxchange.org Git - friendica.git/blob - tests/src/Console/AutomaticInstallationConsoleTest.php
Merge remote-tracking branch 'upstream/develop' into item-view
[friendica.git] / tests / src / Console / AutomaticInstallationConsoleTest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Console;
23
24 use Dice\Dice;
25 use Friendica\App;
26 use Friendica\Console\AutomaticInstallation;
27 use Friendica\Core\Config\Cache;
28 use Friendica\Core\Installer;
29 use Friendica\Core\L10n;
30 use Friendica\Core\Logger;
31 use Friendica\Database\Database;
32 use Friendica\DI;
33 use Friendica\Test\Util\DBAMockTrait;
34 use Friendica\Test\Util\DBStructureMockTrait;
35 use Friendica\Test\Util\RendererMockTrait;
36 use Friendica\Test\Util\VFSTrait;
37 use Friendica\Util\Logger\VoidLogger;
38 use Mockery;
39 use Mockery\MockInterface;
40 use org\bovigo\vfs\vfsStream;
41 use org\bovigo\vfs\vfsStreamFile;
42
43 class AutomaticInstallationConsoleTest extends ConsoleTest
44 {
45         use VFSTrait;
46         use DBAMockTrait;
47         use DBStructureMockTrait;
48         use RendererMockTrait;
49
50         /**
51          * @var vfsStreamFile Assert file without DB credentials
52          */
53         private $assertFile;
54         /**
55          * @var vfsStreamFile Assert file with DB credentials
56          */
57         private $assertFileDb;
58
59         /**
60          * @var Cache The configuration cache to check after each test
61          */
62         private $configCache;
63
64         /**
65          * @var App\Mode
66          */
67         private $appMode;
68
69         /**
70          * @var Database
71          */
72         private $dba;
73
74         /**
75          * @var Dice|MockInterface
76          */
77         private $dice;
78
79         public function setUp()
80         {
81                 static::markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
82
83                 parent::setUp();
84
85                 $this->setUpVfsDir();;
86
87                 if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
88                         $this->root->getChild('config')
89                                 ->removeChild('local.config.php');
90                 }
91                 $this->dice = Mockery::mock(Dice::class)->makePartial();
92
93                 $l10nMock = Mockery::mock(L10n::class);
94                 $l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
95
96                 $this->dice->shouldReceive('create')
97                            ->with(L10n::class)
98                            ->andReturn($l10nMock);
99
100                 DI::init($this->dice);
101
102                 $this->configCache = new Cache();
103                 $this->configCache->set('system', 'basepath', $this->root->url());
104                 $this->configCache->set('config', 'php_path', trim(shell_exec('which php')));
105                 $this->configCache->set('system', 'theme', 'smarty3');
106
107                 $this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) {
108                         if ($key !== 'basepath') {
109                                 return $this->configCache->set($cat, $key, $value);
110                         } else {
111                                 return true;
112                         }
113                 });
114
115                 $this->configMock->shouldReceive('has')->andReturn(true);
116                 $this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) {
117                         return $this->configCache->get($cat, $key);
118                 });
119                 $this->configMock->shouldReceive('load')->andReturnUsing(function ($config, $overwrite = false) {
120                         $this->configCache->load($config, $overwrite);
121                 });
122
123                 $this->mode->shouldReceive('isInstall')->andReturn(true);
124                 Logger::init(new VoidLogger());
125         }
126
127         /**
128          * Returns the dataset for each automatic installation test
129          *
130          * @return array the dataset
131          */
132         public function dataInstaller()
133         {
134                 return [
135                         'empty' => [
136                                 'data' => [
137                                         'database' => [
138                                                 'hostname'    => '',
139                                                 'username'    => '',
140                                                 'password'    => '',
141                                                 'database'    => '',
142                                                 'port'        => '',
143                                         ],
144                                         'config' => [
145                                                 'php_path'    => '',
146                                                 'hostname'    => 'friendica.local',
147                                                 'admin_email' => '',
148                                         ],
149                                         'system' => [
150                                                 'basepath'    => '',
151                                                 'urlpath'     => '',
152                                                 'url'         => 'http://friendica.local',
153                                                 'ssl_policy'  => 0,
154                                                 'default_timezone' => '',
155                                                 'language'    => '',
156                                         ],
157                                 ],
158                         ],
159                         'normal' => [
160                                 'data' => [
161                                         'database' => [
162                                                 'hostname'    => 'testhost',
163                                                 'port'        => 3306,
164                                                 'username'    => 'friendica',
165                                                 'password'    => 'a password',
166                                                 'database'    => 'database',
167                                         ],
168                                         'config' => [
169                                                 'php_path'    => '',
170                                                 'hostname'    => 'friendica.local',
171                                                 'admin_email' => 'admin@philipp.info',
172                                         ],
173                                         'system' => [
174                                                 'urlpath'     => 'test/it',
175                                                 'url'         => 'http://friendica.local/test/it',
176                                                 'basepath'    => '',
177                                                 'ssl_policy'  => '2',
178                                                 'default_timezone' => 'en',
179                                                 'language'    => 'Europe/Berlin',
180                                         ],
181                                 ],
182                         ],
183                         'special' => [
184                                 'data' => [
185                                         'database' => [
186                                                 'hostname'    => 'testhost.new.domain',
187                                                 'port'        => 3341,
188                                                 'username'    => 'fr"§%ica',
189                                                 'password'    => '$%\"gse',
190                                                 'database'    => 'db',
191                                         ],
192                                         'config' => [
193                                                 'php_path'    => '',
194                                                 'hostname'    => 'friendica.local',
195                                                 'admin_email' => 'admin@philipp.info',
196                                         ],
197                                         'system' => [
198                                                 'urlpath'     => 'test/it',
199                                                 'url'         => 'https://friendica.local/test/it',
200                                                 'basepath'    => '',
201                                                 'ssl_policy'  => '1',
202                                                 'default_timezone' => 'en',
203                                                 'language'    => 'Europe/Berlin',
204                                         ],
205                                 ],
206                         ],
207                 ];
208         }
209
210         private function assertFinished($txt, $withconfig = false, $copyfile = false)
211         {
212                 $cfg = '';
213
214                 if ($withconfig) {
215                         $cfg = <<<CFG
216
217
218 Creating config file...
219
220  Complete!
221 CFG;
222                 }
223
224                 if ($copyfile) {
225                         $cfg = <<<CFG
226
227
228 Copying config file...
229
230  Complete!
231 CFG;
232                 }
233
234                 $finished = <<<FIN
235 Initializing setup...
236
237  Complete!
238
239
240 Checking environment...
241
242  NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.
243
244  Complete!
245 {$cfg}
246
247
248 Checking database...
249
250  Complete!
251
252
253 Inserting data into database...
254
255  Complete!
256
257
258 Installing theme
259
260  Complete
261
262
263
264 Installation is finished
265
266
267 FIN;
268                 self::assertEquals($finished, $txt);
269         }
270
271         private function assertStuckDB($txt)
272         {
273                 $finished = <<<FIN
274 Initializing setup...
275
276  Complete!
277
278
279 Checking environment...
280
281  NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.
282
283  Complete!
284
285
286 Creating config file...
287
288  Complete!
289
290
291 Checking database...
292
293 [Error] --------
294 Could not connect to database.: 
295
296
297 FIN;
298
299                 self::assertEquals($finished, $txt);
300         }
301
302         private function assertStuckURL($txt)
303         {
304                 $finished = <<<FIN
305 Initializing setup...
306
307  Complete!
308
309
310 Checking environment...
311
312  NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.
313
314  Complete!
315
316
317 Creating config file...
318
319 The Friendica URL has to be set during CLI installation.
320
321 FIN;
322
323                 self::assertEquals($finished, $txt);
324         }
325
326         /**
327          * Asserts one config entry
328          *
329          * @param string     $cat           The category to test
330          * @param string     $key           The key to test
331          * @param null|array $assertion     The asserted value (null = empty, or array/string)
332          * @param string     $default_value The default value
333          */
334         public function assertConfigEntry($cat, $key, $assertion = null, $default_value = null)
335         {
336                 if (!empty($assertion[$cat][$key])) {
337                         self::assertEquals($assertion[$cat][$key], $this->configCache->get($cat, $key));
338                 } elseif (!empty($assertion) && !is_array($assertion)) {
339                         self::assertEquals($assertion, $this->configCache->get($cat, $key));
340                 } elseif (!empty($default_value)) {
341                         self::assertEquals($default_value, $this->configCache->get($cat, $key));
342                 } else {
343                         self::assertEmpty($this->configCache->get($cat, $key), $this->configCache->get($cat, $key));
344                 }
345         }
346
347         /**
348          * Asserts all config entries
349          *
350          * @param null|array $assertion    The optional assertion array
351          * @param boolean    $saveDb       True, if the db credentials should get saved to the file
352          * @param boolean    $default      True, if we use the default values
353          * @param boolean    $defaultDb    True, if we use the default value for the DB
354          * @param boolean    $realBasepath True, if we use the real basepath of the installation, not the mocked one
355          */
356         public function assertConfig($assertion = null, $saveDb = false, $default = true, $defaultDb = true, $realBasepath = false)
357         {
358                 if (!empty($assertion['database']['hostname'])) {
359                         $assertion['database']['hostname'] .= (!empty($assertion['database']['port']) ? ':' . $assertion['database']['port'] : '');
360                 }
361
362                 self::assertConfigEntry('database', 'hostname', ($saveDb) ? $assertion : null, (!$saveDb || $defaultDb) ? Installer::DEFAULT_HOST : null);
363                 self::assertConfigEntry('database', 'username', ($saveDb) ? $assertion : null);
364                 self::assertConfigEntry('database', 'password', ($saveDb) ? $assertion : null);
365                 self::assertConfigEntry('database', 'database', ($saveDb) ? $assertion : null);
366
367                 self::assertConfigEntry('config', 'admin_email', $assertion);
368                 self::assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
369                 self::assertConfigEntry('config', 'hostname', $assertion);
370
371                 self::assertConfigEntry('system', 'default_timezone', $assertion, ($default) ? Installer::DEFAULT_TZ : null);
372                 self::assertConfigEntry('system', 'language', $assertion, ($default) ? Installer::DEFAULT_LANG : null);
373                 self::assertConfigEntry('system', 'url', $assertion);
374                 self::assertConfigEntry('system', 'urlpath', $assertion);
375                 self::assertConfigEntry('system', 'ssl_policy', $assertion, ($default) ? App\BaseURL::DEFAULT_SSL_SCHEME : null);
376                 self::assertConfigEntry('system', 'basepath', ($realBasepath) ? $this->root->url() : $assertion);
377         }
378
379         /**
380          * Test the automatic installation without any parameter/setting
381          * Should stuck because of missing hostname
382          */
383         public function testEmpty()
384         {
385                 $console = new AutomaticInstallation($this->consoleArgv);
386
387                 $txt = $this->dumpExecute($console);
388
389                 self::assertStuckURL($txt);
390         }
391
392         /**
393          * Test the automatic installation without any parameter/setting
394          * except URL
395          */
396         public function testEmptyWithURL()
397         {
398                 $this->mockConnect(true, 1);
399                 $this->mockConnected(true, 1);
400                 $this->mockExistsTable('user', false, 1);
401                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
402
403                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
404                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
405
406                 $console = new AutomaticInstallation($this->consoleArgv);
407                 $console->setOption('url', 'http://friendica.local');
408
409                 $txt = $this->dumpExecute($console);
410
411                 self::assertFinished($txt, true, false);
412                 self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
413
414                 self::assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlPath' => '']], false, true, true, true);
415         }
416
417         /**
418          * Test the automatic installation with a prepared config file
419          * @dataProvider dataInstaller
420          */
421         public function testWithConfig(array $data)
422         {
423                 $this->mockConnect(true, 1);
424                 $this->mockConnected(true, 1);
425                 $this->mockExistsTable('user', false, 1);
426                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
427
428                 $conf = function ($cat, $key) use ($data) {
429                         if ($cat == 'database' && $key == 'hostname' && !empty($data['database']['port'])) {
430                                 return $data[$cat][$key] . ':' . $data['database']['port'];
431                         }
432                         return $data[$cat][$key];
433                 };
434
435                 $config = <<<CONF
436 <?php
437
438 // Local configuration
439
440 // If you're unsure about what any of the config keys below do, please check the static/defaults.config.php for detailed
441 // documentation of their data type and behavior.
442
443 return [
444         'database' => [
445                 'hostname' => '{$conf('database', 'hostname')}',
446                 'username' => '{$conf('database', 'username')}',
447                 'password' => '{$conf('database', 'password')}',
448                 'database' => '{$conf('database', 'database')}',
449                 'charset' => 'utf8mb4',
450         ],
451
452         // ****************************************************************
453         // The configuration below will be overruled by the admin panel.
454         // Changes made below will only have an effect if the database does
455         // not contain any configuration for the friendica system.
456         // ****************************************************************
457
458         'config' => [
459                 'admin_email' => '{$conf('config', 'admin_email')}',
460                 'hostname' => '{$conf('config', 'hostname')}',
461                 'sitename' => 'Friendica Social Network',
462                 'register_policy' => \Friendica\Module\Register::OPEN,
463                 'register_text' => '',
464         ],
465         'system' => [
466                 'basepath' => '{$conf('system', 'basepath')}',
467                 'urlpath' => '{$conf('system', 'urlpath')}',
468                 'url' => '{$conf('system', 'url')}',
469                 'ssl_policy' => '{$conf('system', 'ssl_policy')}',
470                 'default_timezone' => '{$conf('system', 'default_timezone')}',
471                 'language' => '{$conf('system', 'language')}',
472         ],
473 ];
474 CONF;
475
476                 vfsStream::newFile('prepared.config.php')
477                         ->at($this->root)
478                         ->setContent($config);
479
480                 $console = new AutomaticInstallation($this->consoleArgv);
481                 $console->setOption('f', 'prepared.config.php');
482
483                 $txt = $this->dumpExecute($console);
484
485                 self::assertFinished($txt, false, true);
486
487                 self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
488                 self::assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
489
490                 self::assertConfig($data, true, false, false);
491         }
492
493         /**
494          * Test the automatic installation with environment variables
495          * Includes saving the DB credentials to the file
496          * @dataProvider dataInstaller
497          */
498         public function testWithEnvironmentAndSave(array $data)
499         {
500                 $this->mockConnect(true, 1);
501                 $this->mockConnected(true, 1);
502                 $this->mockExistsTable('user', false, 1);
503                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
504
505                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
506                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
507
508                 self::assertTrue(putenv('MYSQL_HOST='     . $data['database']['hostname']));
509                 self::assertTrue(putenv('MYSQL_PORT='     . $data['database']['port']));
510                 self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
511                 self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
512                 self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
513
514                 self::assertTrue(putenv('FRIENDICA_HOSTNAME='   . $data['config']['hostname']));
515                 self::assertTrue(putenv('FRIENDICA_BASE_PATH='  . $data['system']['basepath']));
516                 self::assertTrue(putenv('FRIENDICA_URL='        . $data['system']['url']));
517                 self::assertTrue(putenv('FRIENDICA_PHP_PATH='   . $data['config']['php_path']));
518                 self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
519                 self::assertTrue(putenv('FRIENDICA_TZ='         . $data['system']['default_timezone']));
520                 self::assertTrue(putenv('FRIENDICA_LANG='       . $data['system']['language']));
521
522                 $console = new AutomaticInstallation($this->consoleArgv);
523                 $console->setOption('savedb', true);
524
525                 $txt = $this->dumpExecute($console);
526
527                 self::assertFinished($txt, true);
528                 self::assertConfig($data, true, true, false, true);
529         }
530
531         /**
532          * Test the automatic installation with environment variables
533          * Don't save the db credentials to the file
534          * @dataProvider dataInstaller
535          */
536         public function testWithEnvironmentWithoutSave(array $data)
537         {
538                 $this->mockConnect(true, 1);
539                 $this->mockConnected(true, 1);
540                 $this->mockExistsTable('user', false, 1);
541                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
542
543                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
544                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
545
546                 self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
547                 self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
548                 self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
549                 self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
550                 self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
551
552                 self::assertTrue(putenv('FRIENDICA_HOSTNAME='   . $data['config']['hostname']));
553                 self::assertTrue(putenv('FRIENDICA_BASE_PATH='  . $data['system']['basepath']));
554                 self::assertTrue(putenv('FRIENDICA_URL='        . $data['system']['url']));
555                 self::assertTrue(putenv('FRIENDICA_PHP_PATH='   . $data['config']['php_path']));
556                 self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
557                 self::assertTrue(putenv('FRIENDICA_TZ='         . $data['system']['default_timezone']));
558                 self::assertTrue(putenv('FRIENDICA_LANG='       . $data['system']['language']));
559
560                 $console = new AutomaticInstallation($this->consoleArgv);
561
562                 $txt = $this->dumpExecute($console);
563
564                 self::assertFinished($txt, true);
565                 self::assertConfig($data, false, true, false, true);
566         }
567
568         /**
569          * Test the automatic installation with arguments
570          * @dataProvider dataInstaller
571          */
572         public function testWithArguments(array $data)
573         {
574                 $this->mockConnect(true, 1);
575                 $this->mockConnected(true, 1);
576                 $this->mockExistsTable('user', false, 1);
577                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
578
579                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
580                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
581
582                 $console = new AutomaticInstallation($this->consoleArgv);
583
584                 $option = function($var, $cat, $key) use ($data, $console) {
585                         if (!empty($data[$cat][$key])) {
586                                 $console->setOption($var, $data[$cat][$key]);
587                         }
588                 };
589                 $option('dbhost'    , 'database', 'hostname');
590                 $option('dbport'    , 'database', 'port');
591                 $option('dbuser'    , 'database', 'username');
592                 $option('dbpass'    , 'database', 'password');
593                 $option('dbdata'    , 'database', 'database');
594                 $option('url'       , 'system'  , 'url');
595                 $option('phppath'   , 'config'  , 'php_path');
596                 $option('admin'     , 'config'  , 'admin_email');
597                 $option('tz'        , 'system'  , 'default_timezone');
598                 $option('lang'      , 'system'  , 'language');
599                 $option('basepath'  , 'system'  , 'basepath');
600
601                 $txt = $this->dumpExecute($console);
602
603                 self::assertFinished($txt, true);
604                 self::assertConfig($data, true, true, true, true);
605         }
606
607         /**
608          * Test the automatic installation with a wrong database connection
609          */
610         public function testNoDatabaseConnection()
611         {
612                 $this->mockConnect(false, 1);
613
614                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
615                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
616
617                 $console = new AutomaticInstallation($this->consoleArgv);
618                 $console->setOption('url', 'http://friendica.local');
619
620                 $txt = $this->dumpExecute($console);
621
622                 self::assertStuckDB($txt);
623                 self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
624
625                 self::assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlpath' => '']], false, true, false, true);
626         }
627
628         public function testGetHelp()
629         {
630                 // Usable to purposely fail if new commands are added without taking tests into account
631                 $theHelp = <<<HELP
632 Installation - Install Friendica automatically
633 Synopsis
634         bin/console autoinstall [-h|--help|-?] [-v] [-a] [-f]
635
636 Description
637     Installs Friendica with data based on the local.config.php file or environment variables
638
639 Notes
640     Not checking .htaccess/URL-Rewrite during CLI installation.
641
642 Options
643     -h|--help|-?            Show help information
644     -v                      Show more debug information.
645     -a                      All setup checks are required (except .htaccess)
646     -f|--file <config>      prepared config file (e.g. "config/local.config.php" itself) which will override every other config option - except the environment variables)
647     -s|--savedb               Save the DB credentials to the file (if environment variables is used)
648     -H|--dbhost <host>        The host of the mysql/mariadb database (env MYSQL_HOST)
649     -p|--dbport <port>        The port of the mysql/mariadb database (env MYSQL_PORT)
650     -d|--dbdata <database>    The name of the mysql/mariadb database (env MYSQL_DATABASE)
651     -U|--dbuser <username>    The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
652     -P|--dbpass <password>    The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
653     -U|--url <url>            The full base URL of Friendica - f.e. 'https://friendica.local/sub' (env FRIENDICA_URL) 
654     -B|--phppath <php_path>   The path of the PHP binary (env FRIENDICA_PHP_PATH)
655     -b|--basepath <base_path> The basepath of Friendica (env FRIENDICA_BASE_PATH)
656     -t|--tz <timezone>        The timezone of Friendica (env FRIENDICA_TZ)
657     -L|--lang <language>      The language of Friendica (env FRIENDICA_LANG)
658  
659 Environment variables
660    MYSQL_HOST                  The host of the mysql/mariadb database (mandatory if mysql and environment is used)
661    MYSQL_PORT                  The port of the mysql/mariadb database
662    MYSQL_USERNAME|MYSQL_USER   The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
663    MYSQL_PASSWORD              The password of the mysql/mariadb database login
664    MYSQL_DATABASE              The name of the mysql/mariadb database
665    FRIENDICA_URL               The full base URL of Friendica - f.e. 'https://friendica.local/sub'
666    FRIENDICA_PHP_PATH          The path of the PHP binary - leave empty for auto detection
667    FRIENDICA_BASE_PATH         The basepath of Friendica - leave empty for auto detection
668    FRIENDICA_ADMIN_MAIL        The admin email address of Friendica (this email will be used for admin access)
669    FRIENDICA_TZ                The timezone of Friendica
670    FRIENDICA_LANG              The langauge of Friendica
671    
672 Examples
673         bin/console autoinstall -f 'input.config.php
674                 Installs Friendica with the prepared 'input.config.php' file
675
676         bin/console autoinstall --savedb
677                 Installs Friendica with environment variables and saves them to the 'config/local.config.php' file
678
679         bin/console autoinstall -h localhost -p 3365 -U user -P passwort1234 -d friendica
680                 Installs Friendica with a local mysql database with credentials
681
682 HELP;
683
684                 $console = new AutomaticInstallation($this->consoleArgv);
685                 $console->setOption('help', true);
686
687                 $txt = $this->dumpExecute($console);
688
689                 self::assertEquals($theHelp, $txt);
690         }
691 }