namespace Friendica\Test\src\Core\Console;
+use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Console\AutomaticInstallation;
+use Friendica\Core\Installer;
use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\DBStructureMockTrait;
use Friendica\Test\Util\L10nMockTrait;
}
$this->db_host = getenv('MYSQL_HOST');
- $this->db_port = (!empty(getenv('MYSQL_PORT'))) ? getenv('MYSQL_PORT') : null;
+ $this->db_port = !empty(getenv('MYSQL_PORT')) ? getenv('MYSQL_PORT') : null;
$this->db_data = getenv('MYSQL_DATABASE');
$this->db_user = getenv('MYSQL_USERNAME') . getenv('MYSQL_USER');
$this->db_pass = getenv('MYSQL_PASSWORD');
- $this->mockConfigGet('config', 'php_path', false);
-
$this->mockL10nT();
}
'$dbuser' => (($withDb) ? $this->db_user : ''),
'$dbpass' => (($withDb) ? $this->db_pass : ''),
'$dbdata' => (($withDb) ? $this->db_data : ''),
- '$timezone' => 'Europe/Berlin',
- '$language' => 'de',
+ '$timezone' => Installer::DEFAULT_TZ,
+ '$language' => Installer::DEFAULT_LANG,
'$urlpath' => '/friendica',
+ '$basepath' => '/test',
+ '$hostname' => 'friendica.local',
'$adminmail' => 'admin@friendica.local'
];
$this->assertEquals($finished, $txt);
}
+ public function dataInstaller()
+ {
+ return [
+ 'empty' => [
+ 'data' => [
+ 'database' => [
+ 'hostname' => '',
+ 'username' => '',
+ 'password' => '',
+ 'database' => '',
+ ],
+ 'config' => [
+ 'php_path' => '',
+ 'hostname' => '',
+ 'admin_email' => '',
+ ],
+ 'system' => [
+ 'urlpath' => '',
+ 'basepath' => '',
+ 'ssl_policy' => '',
+ 'default_timezone' => '',
+ 'language' => '',
+ ],
+ ],
+ ]
+ ];
+ }
+
+ /**
+ * Test the automatic installation without any parameter
+ * @dataProvider dataInstaller
+ */
+ public function testEmpty(array $data)
+ {
+ $configCache = new ConfigCache();
+ $configCache->load($data);
+ $configCache->set('system', 'basepath', $this->root->url());
+
+ $this->mockApp($this->root, $configCache);
+
+ $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(), '', 1);
+
+ $console = new AutomaticInstallation($this->consoleArgv);
+
+ $txt = $this->dumpExecute($console);
+
+ $this->assertEquals(Installer::DEFAULT_LANG, $configCache->get('system', 'language'));
+ $this->assertEquals(Installer::DEFAULT_TZ, $configCache->get('system', 'default_timezone'));
+ $this->assertEquals(Installer::DEFAULT_HOST, $configCache->get('database', 'hostname'));
+ $this->assertFinished($txt, true, false);
+
+ }
+
/**
* @medium
+ * @dataProvider dataInstaller
*/
- public function testWithConfig()
+ public function testWithConfig(array $data)
{
$this->mockConnect(true, 1);
$this->mockConnected(true, 1);
$this->mockExistsTable('user', false, 1);
- $this->mockUpdate([false, true, true], null, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
$config = <<<CONF
<?php
'config' => [
'admin_email' => '',
'sitename' => 'Friendica Social Network',
- 'register_policy' => REGISTER_OPEN,
+ 'register_policy' => \Friendica\Module\Register::OPEN,
'register_text' => '',
],
'system' => [
$this->mockConnect(true, 1);
$this->mockConnected(true, 1);
$this->mockExistsTable('user', false, 1);
- $this->mockUpdate([false, true, true], null, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(true), '', 1);
$this->mockConnect(true, 1);
$this->mockConnected(true, 1);
$this->mockExistsTable('user', false, 1);
- $this->mockUpdate([false, true, true], null, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(false), '', 1);
$this->mockConnect(true, 1);
$this->mockConnected(true, 1);
$this->mockExistsTable('user', false, 1);
- $this->mockUpdate([false, true, true], null, 1);
+ $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(true), '', 1);