+ /**
+ * Test the automatic installation with a prepared config file
+ * @dataProvider dataInstaller
+ */
+ public function testWithConfig(array $data)
+ {
+ $this->mockConnect(true, 1);
+ $this->mockConnected(true, 1);
+ $this->mockExistsTable('user', false, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
+
+ $conf = function ($cat, $key) use ($data) {
+ if ($cat == 'database' && $key == 'hostname' && !empty($data['database']['port'])) {
+ return $data[$cat][$key] . ':' . $data['database']['port'];
+ }
+ return $data[$cat][$key];
+ };
+
+ $config = <<<CONF
+<?php
+
+// Local configuration
+
+// If you're unsure about what any of the config keys below do, please check the config/defaults.config.php for detailed
+// documentation of their data type and behavior.
+
+return [
+ 'database' => [
+ 'hostname' => '{$conf('database', 'hostname')}',
+ 'username' => '{$conf('database', 'username')}',
+ 'password' => '{$conf('database', 'password')}',
+ 'database' => '{$conf('database', 'database')}',
+ 'charset' => 'utf8mb4',
+ ],
+
+ // ****************************************************************
+ // The configuration below will be overruled by the admin panel.
+ // Changes made below will only have an effect if the database does
+ // not contain any configuration for the friendica system.
+ // ****************************************************************
+
+ 'config' => [
+ 'admin_email' => '{$conf('config', 'admin_email')}',
+ 'hostname' => '{$conf('config', 'hostname')}',
+ 'sitename' => 'Friendica Social Network',
+ 'register_policy' => \Friendica\Module\Register::OPEN,
+ 'register_text' => '',
+ ],
+ 'system' => [
+ 'basepath' => '{$conf('system', 'basepath')}',
+ 'urlpath' => '{$conf('system', 'urlpath')}',
+ 'url' => '{$conf('system', 'url')}',
+ 'ssl_policy' => '{$conf('system', 'ssl_policy')}',
+ 'default_timezone' => '{$conf('system', 'default_timezone')}',
+ 'language' => '{$conf('system', 'language')}',
+ ],
+];
+CONF;
+
+ vfsStream::newFile('prepared.config.php')
+ ->at($this->root)
+ ->setContent($config);
+
+ $console = new AutomaticInstallation($this->consoleArgv);
+ $console->setOption('f', 'prepared.config.php');
+
+ $txt = $this->dumpExecute($console);
+
+ $this->assertFinished($txt, false, true);
+
+ $this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
+ $this->assertEquals($config, file_get_contents($this->root->getChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')->url()));
+
+ $this->assertConfig($data, true, false, false);
+ }