]> git.mxchange.org Git - friendica.git/blob - tests/src/Console/AutomaticInstallationConsoleTest.php
Add expected mocked calls to BBCodeTest
[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                 'pdo_emulate_prepares' => false,
451         ],
452
453         // ****************************************************************
454         // The configuration below will be overruled by the admin panel.
455         // Changes made below will only have an effect if the database does
456         // not contain any configuration for the friendica system.
457         // ****************************************************************
458
459         'config' => [
460                 'admin_email' => '{$conf('config', 'admin_email')}',
461                 'hostname' => '{$conf('config', 'hostname')}',
462                 'sitename' => 'Friendica Social Network',
463                 'register_policy' => \Friendica\Module\Register::OPEN,
464                 'register_text' => '',
465         ],
466         'system' => [
467                 'basepath' => '{$conf('system', 'basepath')}',
468                 'urlpath' => '{$conf('system', 'urlpath')}',
469                 'url' => '{$conf('system', 'url')}',
470                 'ssl_policy' => '{$conf('system', 'ssl_policy')}',
471                 'default_timezone' => '{$conf('system', 'default_timezone')}',
472                 'language' => '{$conf('system', 'language')}',
473         ],
474 ];
475 CONF;
476
477                 vfsStream::newFile('prepared.config.php')
478                         ->at($this->root)
479                         ->setContent($config);
480
481                 $console = new AutomaticInstallation($this->consoleArgv);
482                 $console->setOption('f', 'prepared.config.php');
483
484                 $txt = $this->dumpExecute($console);
485
486                 self::assertFinished($txt, false, true);
487
488                 self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
489                 self::assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
490
491                 self::assertConfig($data, true, false, false);
492         }
493
494         /**
495          * Test the automatic installation with environment variables
496          * Includes saving the DB credentials to the file
497          * @dataProvider dataInstaller
498          */
499         public function testWithEnvironmentAndSave(array $data)
500         {
501                 $this->mockConnect(true, 1);
502                 $this->mockConnected(true, 1);
503                 $this->mockExistsTable('user', false, 1);
504                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
505
506                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
507                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
508
509                 self::assertTrue(putenv('MYSQL_HOST='     . $data['database']['hostname']));
510                 self::assertTrue(putenv('MYSQL_PORT='     . $data['database']['port']));
511                 self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
512                 self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
513                 self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
514
515                 self::assertTrue(putenv('FRIENDICA_HOSTNAME='   . $data['config']['hostname']));
516                 self::assertTrue(putenv('FRIENDICA_BASE_PATH='  . $data['system']['basepath']));
517                 self::assertTrue(putenv('FRIENDICA_URL='        . $data['system']['url']));
518                 self::assertTrue(putenv('FRIENDICA_PHP_PATH='   . $data['config']['php_path']));
519                 self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
520                 self::assertTrue(putenv('FRIENDICA_TZ='         . $data['system']['default_timezone']));
521                 self::assertTrue(putenv('FRIENDICA_LANG='       . $data['system']['language']));
522
523                 $console = new AutomaticInstallation($this->consoleArgv);
524                 $console->setOption('savedb', true);
525
526                 $txt = $this->dumpExecute($console);
527
528                 self::assertFinished($txt, true);
529                 self::assertConfig($data, true, true, false, true);
530         }
531
532         /**
533          * Test the automatic installation with environment variables
534          * Don't save the db credentials to the file
535          * @dataProvider dataInstaller
536          */
537         public function testWithEnvironmentWithoutSave(array $data)
538         {
539                 $this->mockConnect(true, 1);
540                 $this->mockConnected(true, 1);
541                 $this->mockExistsTable('user', false, 1);
542                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
543
544                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
545                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
546
547                 self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
548                 self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
549                 self::assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
550                 self::assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
551                 self::assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
552
553                 self::assertTrue(putenv('FRIENDICA_HOSTNAME='   . $data['config']['hostname']));
554                 self::assertTrue(putenv('FRIENDICA_BASE_PATH='  . $data['system']['basepath']));
555                 self::assertTrue(putenv('FRIENDICA_URL='        . $data['system']['url']));
556                 self::assertTrue(putenv('FRIENDICA_PHP_PATH='   . $data['config']['php_path']));
557                 self::assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
558                 self::assertTrue(putenv('FRIENDICA_TZ='         . $data['system']['default_timezone']));
559                 self::assertTrue(putenv('FRIENDICA_LANG='       . $data['system']['language']));
560
561                 $console = new AutomaticInstallation($this->consoleArgv);
562
563                 $txt = $this->dumpExecute($console);
564
565                 self::assertFinished($txt, true);
566                 self::assertConfig($data, false, true, false, true);
567         }
568
569         /**
570          * Test the automatic installation with arguments
571          * @dataProvider dataInstaller
572          */
573         public function testWithArguments(array $data)
574         {
575                 $this->mockConnect(true, 1);
576                 $this->mockConnected(true, 1);
577                 $this->mockExistsTable('user', false, 1);
578                 $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
579
580                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
581                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
582
583                 $console = new AutomaticInstallation($this->consoleArgv);
584
585                 $option = function($var, $cat, $key) use ($data, $console) {
586                         if (!empty($data[$cat][$key])) {
587                                 $console->setOption($var, $data[$cat][$key]);
588                         }
589                 };
590                 $option('dbhost'    , 'database', 'hostname');
591                 $option('dbport'    , 'database', 'port');
592                 $option('dbuser'    , 'database', 'username');
593                 $option('dbpass'    , 'database', 'password');
594                 $option('dbdata'    , 'database', 'database');
595                 $option('url'       , 'system'  , 'url');
596                 $option('phppath'   , 'config'  , 'php_path');
597                 $option('admin'     , 'config'  , 'admin_email');
598                 $option('tz'        , 'system'  , 'default_timezone');
599                 $option('lang'      , 'system'  , 'language');
600                 $option('basepath'  , 'system'  , 'basepath');
601
602                 $txt = $this->dumpExecute($console);
603
604                 self::assertFinished($txt, true);
605                 self::assertConfig($data, true, true, true, true);
606         }
607
608         /**
609          * Test the automatic installation with a wrong database connection
610          */
611         public function testNoDatabaseConnection()
612         {
613                 $this->mockConnect(false, 1);
614
615                 $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
616                 $this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
617
618                 $console = new AutomaticInstallation($this->consoleArgv);
619                 $console->setOption('url', 'http://friendica.local');
620
621                 $txt = $this->dumpExecute($console);
622
623                 self::assertStuckDB($txt);
624                 self::assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
625
626                 self::assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlpath' => '']], false, true, false, true);
627         }
628
629         public function testGetHelp()
630         {
631                 // Usable to purposely fail if new commands are added without taking tests into account
632                 $theHelp = <<<HELP
633 Installation - Install Friendica automatically
634 Synopsis
635         bin/console autoinstall [-h|--help|-?] [-v] [-a] [-f]
636
637 Description
638     Installs Friendica with data based on the local.config.php file or environment variables
639
640 Notes
641     Not checking .htaccess/URL-Rewrite during CLI installation.
642
643 Options
644     -h|--help|-?            Show help information
645     -v                      Show more debug information.
646     -a                      All setup checks are required (except .htaccess)
647     -f|--file <config>      prepared config file (e.g. "config/local.config.php" itself) which will override every other config option - except the environment variables)
648     -s|--savedb               Save the DB credentials to the file (if environment variables is used)
649     -H|--dbhost <host>        The host of the mysql/mariadb database (env MYSQL_HOST)
650     -p|--dbport <port>        The port of the mysql/mariadb database (env MYSQL_PORT)
651     -d|--dbdata <database>    The name of the mysql/mariadb database (env MYSQL_DATABASE)
652     -U|--dbuser <username>    The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
653     -P|--dbpass <password>    The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
654     -U|--url <url>            The full base URL of Friendica - f.e. 'https://friendica.local/sub' (env FRIENDICA_URL) 
655     -B|--phppath <php_path>   The path of the PHP binary (env FRIENDICA_PHP_PATH)
656     -b|--basepath <base_path> The basepath of Friendica (env FRIENDICA_BASE_PATH)
657     -t|--tz <timezone>        The timezone of Friendica (env FRIENDICA_TZ)
658     -L|--lang <language>      The language of Friendica (env FRIENDICA_LANG)
659  
660 Environment variables
661    MYSQL_HOST                  The host of the mysql/mariadb database (mandatory if mysql and environment is used)
662    MYSQL_PORT                  The port of the mysql/mariadb database
663    MYSQL_USERNAME|MYSQL_USER   The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
664    MYSQL_PASSWORD              The password of the mysql/mariadb database login
665    MYSQL_DATABASE              The name of the mysql/mariadb database
666    FRIENDICA_URL               The full base URL of Friendica - f.e. 'https://friendica.local/sub'
667    FRIENDICA_PHP_PATH          The path of the PHP binary - leave empty for auto detection
668    FRIENDICA_BASE_PATH         The basepath of Friendica - leave empty for auto detection
669    FRIENDICA_ADMIN_MAIL        The admin email address of Friendica (this email will be used for admin access)
670    FRIENDICA_TZ                The timezone of Friendica
671    FRIENDICA_LANG              The langauge of Friendica
672    
673 Examples
674         bin/console autoinstall -f 'input.config.php
675                 Installs Friendica with the prepared 'input.config.php' file
676
677         bin/console autoinstall --savedb
678                 Installs Friendica with environment variables and saves them to the 'config/local.config.php' file
679
680         bin/console autoinstall -h localhost -p 3365 -U user -P passwort1234 -d friendica
681                 Installs Friendica with a local mysql database with credentials
682
683 HELP;
684
685                 $console = new AutomaticInstallation($this->consoleArgv);
686                 $console->setOption('help', true);
687
688                 $txt = $this->dumpExecute($console);
689
690                 self::assertEquals($theHelp, $txt);
691         }
692 }