+ private function assertStuckURL($txt)
+ {
+ $finished = <<<FIN
+Initializing setup...
+
+ Complete!
+
+
+Checking environment...
+
+ NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.
+
+ Complete!
+
+
+Creating config file...
+
+The Friendica URL has to be set during CLI installation.
+
+FIN;
+
+ $this->assertEquals($finished, $txt);
+ }
+
+ /**
+ * Asserts one config entry
+ *
+ * @param string $cat The category to test
+ * @param string $key The key to test
+ * @param null|array $assertion The asserted value (null = empty, or array/string)
+ * @param string $default_value The default value
+ */
+ public function assertConfigEntry($cat, $key, $assertion = null, $default_value = null)
+ {
+ if (!empty($assertion[$cat][$key])) {
+ $this->assertEquals($assertion[$cat][$key], $this->configCache->get($cat, $key));
+ } elseif (!empty($assertion) && !is_array($assertion)) {
+ $this->assertEquals($assertion, $this->configCache->get($cat, $key));
+ } elseif (!empty($default_value)) {
+ $this->assertEquals($default_value, $this->configCache->get($cat, $key));
+ } else {
+ $this->assertEmpty($this->configCache->get($cat, $key), $this->configCache->get($cat, $key));
+ }
+ }
+
+ /**
+ * Asserts all config entries
+ *
+ * @param null|array $assertion The optional assertion array
+ * @param boolean $saveDb True, if the db credentials should get saved to the file
+ * @param boolean $default True, if we use the default values
+ * @param boolean $defaultDb True, if we use the default value for the DB
+ * @param boolean $realBasepath True, if we use the real basepath of the installation, not the mocked one
+ */
+ public function assertConfig($assertion = null, $saveDb = false, $default = true, $defaultDb = true, $realBasepath = false)
+ {
+ if (!empty($assertion['database']['hostname'])) {
+ $assertion['database']['hostname'] .= (!empty($assertion['database']['port']) ? ':' . $assertion['database']['port'] : '');
+ }
+
+ $this->assertConfigEntry('database', 'hostname', ($saveDb) ? $assertion : null, (!$saveDb || $defaultDb) ? Installer::DEFAULT_HOST : null);
+ $this->assertConfigEntry('database', 'username', ($saveDb) ? $assertion : null);
+ $this->assertConfigEntry('database', 'password', ($saveDb) ? $assertion : null);
+ $this->assertConfigEntry('database', 'database', ($saveDb) ? $assertion : null);
+
+ $this->assertConfigEntry('config', 'admin_email', $assertion);
+ $this->assertConfigEntry('config', 'php_path', trim(shell_exec('which php')));
+ $this->assertConfigEntry('config', 'hostname', $assertion);
+
+ $this->assertConfigEntry('system', 'default_timezone', $assertion, ($default) ? Installer::DEFAULT_TZ : null);
+ $this->assertConfigEntry('system', 'language', $assertion, ($default) ? Installer::DEFAULT_LANG : null);
+ $this->assertConfigEntry('system', 'url', $assertion);
+ $this->assertConfigEntry('system', 'urlpath', $assertion);
+ $this->assertConfigEntry('system', 'ssl_policy', $assertion, ($default) ? BaseURL::DEFAULT_SSL_SCHEME : null);
+ $this->assertConfigEntry('system', 'basepath', ($realBasepath) ? $this->root->url() : $assertion);
+ }
+
+ /**
+ * Test the automatic installation without any parameter/setting
+ * Should stuck because of missing hostname
+ */
+ public function testEmpty()
+ {
+ $console = new AutomaticInstallation($this->consoleArgv);
+
+ $txt = $this->dumpExecute($console);
+
+ $this->assertStuckURL($txt);
+ }
+
+ /**
+ * Test the automatic installation without any parameter/setting
+ * except URL
+ */
+ public function testEmptyWithURL()
+ {
+ $this->mockConnect(true, 1);
+ $this->mockConnected(true, 1);
+ $this->mockExistsTable('user', false, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
+
+ $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
+ $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+
+ $console = new AutomaticInstallation($this->consoleArgv);
+ $console->setOption('url', 'http://friendica.local');
+
+ $txt = $this->dumpExecute($console);
+
+ $this->assertFinished($txt, true, false);
+ $this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
+
+ $this->assertConfig(['config' => ['hostname' => 'friendica.local'], 'system' => ['url' => 'http://friendica.local', 'ssl_policy' => 0, 'urlPath' => '']], false, true, true, true);
+ }
+