Fixing some AutomaticInstallationConsoleTests
This commit is contained in:
parent
c5973beca4
commit
d4b23ca8b9
|
@ -40,6 +40,7 @@ trait AppMockTrait
|
||||||
*
|
*
|
||||||
* @param vfsStreamDirectory $root The root directory
|
* @param vfsStreamDirectory $root The root directory
|
||||||
* @param Config\Cache\ConfigCache $configCache
|
* @param Config\Cache\ConfigCache $configCache
|
||||||
|
* @param bool $raw If true, no config mocking will be done
|
||||||
*/
|
*/
|
||||||
public function mockApp(vfsStreamDirectory $root, $configCache = null, $raw = false)
|
public function mockApp(vfsStreamDirectory $root, $configCache = null, $raw = false)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +82,7 @@ trait AppMockTrait
|
||||||
$this->app
|
$this->app
|
||||||
->shouldReceive('getBaseUrl')
|
->shouldReceive('getBaseUrl')
|
||||||
->andReturnUsing(function () {
|
->andReturnUsing(function () {
|
||||||
return $this->configMock->get('system', 'url');
|
return $this->app->getConfigCache()->get('system', 'url');
|
||||||
});
|
});
|
||||||
|
|
||||||
BaseObject::setApp($this->app);
|
BaseObject::setApp($this->app);
|
||||||
|
@ -90,6 +91,9 @@ trait AppMockTrait
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->configMock
|
||||||
|
->shouldReceive('has')
|
||||||
|
->andReturn(true);
|
||||||
$this->configMock
|
$this->configMock
|
||||||
->shouldReceive('get')
|
->shouldReceive('get')
|
||||||
->with('database', 'hostname')
|
->with('database', 'hostname')
|
||||||
|
|
|
@ -36,16 +36,20 @@ trait RendererMockTrait
|
||||||
* Mocking the method 'Renderer::replaceMacros()'
|
* Mocking the method 'Renderer::replaceMacros()'
|
||||||
*
|
*
|
||||||
* @param string $template The template to use (normally, it is the mock result of 'mockGetMarkupTemplate()'
|
* @param string $template The template to use (normally, it is the mock result of 'mockGetMarkupTemplate()'
|
||||||
* @param array $args The arguments to pass to the macro
|
* @param array|\Closure|null $args The arguments to pass to the macro
|
||||||
* @param string $return the return value of the mock
|
* @param string $return the return value of the mock
|
||||||
* @param null|int $times How often the method will get used
|
* @param null|int $times How often the method will get used
|
||||||
*/
|
*/
|
||||||
public function mockReplaceMacros($template, $args = [], $return = '', $times = null)
|
public function mockReplaceMacros($template, $args = null, $return = '', $times = null)
|
||||||
{
|
{
|
||||||
if (!isset($this->rendererMock)) {
|
if (!isset($this->rendererMock)) {
|
||||||
$this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
|
$this->rendererMock = \Mockery::mock('alias:' . Renderer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($args)) {
|
||||||
|
$args = [];
|
||||||
|
}
|
||||||
|
|
||||||
$this->rendererMock
|
$this->rendererMock
|
||||||
->shouldReceive('replaceMacros')
|
->shouldReceive('replaceMacros')
|
||||||
->with($template, $args)
|
->with($template, $args)
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Friendica\Test\src\Core\Console;
|
||||||
|
|
||||||
use Friendica\Core\Config\Cache\ConfigCache;
|
use Friendica\Core\Config\Cache\ConfigCache;
|
||||||
use Friendica\Core\Console\AutomaticInstallation;
|
use Friendica\Core\Console\AutomaticInstallation;
|
||||||
|
use Friendica\Core\Installer;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Test\Util\DBAMockTrait;
|
use Friendica\Test\Util\DBAMockTrait;
|
||||||
use Friendica\Test\Util\DBStructureMockTrait;
|
use Friendica\Test\Util\DBStructureMockTrait;
|
||||||
|
@ -14,8 +15,6 @@ use org\bovigo\vfs\vfsStream;
|
||||||
use org\bovigo\vfs\vfsStreamFile;
|
use org\bovigo\vfs\vfsStreamFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runTestsInSeparateProcesses
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
* @requires PHP 7.0
|
* @requires PHP 7.0
|
||||||
*/
|
*/
|
||||||
class AutomaticInstallationConsoleTest extends ConsoleTest
|
class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||||
|
@ -59,33 +58,62 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the arguments which is asserted to be passed to 'replaceMacros()' for creating the local.config.php
|
* Returns the dataset for each automatic installation test
|
||||||
*
|
*
|
||||||
* @param ConfigCache $config The config cache of this test
|
* @return array the dataset
|
||||||
*
|
|
||||||
* @return array The arguments to pass to the mock for 'replaceMacros()'
|
|
||||||
*/
|
*/
|
||||||
private function createArgumentsForMacro(ConfigCache $config)
|
public function dataInstaller()
|
||||||
{
|
{
|
||||||
$args = [
|
return [
|
||||||
'$dbhost' => $config->get('database','hostname'),
|
'empty' => [
|
||||||
'$dbuser' => $config->get('database','username'),
|
'data' => [
|
||||||
'$dbpass' => $config->get('database','password'),
|
'database' => [
|
||||||
'$dbdata' => $config->get('database','database'),
|
'hostname' => '',
|
||||||
|
'username' => '',
|
||||||
'$phpath' => $config->get('config','php_path'),
|
'password' => '',
|
||||||
'$adminmail' => $config->get('config','admin_email'),
|
'database' => '',
|
||||||
'$hostname' => $config->get('config','hostname'),
|
'port' => '',
|
||||||
|
],
|
||||||
'$urlpath' => $config->get('system','urlpath'),
|
'config' => [
|
||||||
'$baseurl' => $config->get('system','url'),
|
'php_path' => '',
|
||||||
'$sslpolicy' => $config->get('system','ssl_policy'),
|
'hostname' => '',
|
||||||
'$timezone' => $config->get('system','default_timezone'),
|
'admin_email' => '',
|
||||||
'$language' => $config->get('system','language'),
|
],
|
||||||
'$basepath' => $config->get('system','basepath'),
|
'system' => [
|
||||||
|
'urlpath' => '',
|
||||||
|
'url' => '',
|
||||||
|
'basepath' => '',
|
||||||
|
'ssl_policy' => '',
|
||||||
|
'default_timezone' => '',
|
||||||
|
'language' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'normal' => [
|
||||||
|
'data' => [
|
||||||
|
'database' => [
|
||||||
|
'hostname' => getenv('MYSQL_HOST'),
|
||||||
|
'port' =>!empty(getenv('MYSQL_PORT')) ? getenv('MYSQL_PORT') : null,
|
||||||
|
'username' => getenv('MYSQL_USERNAME'),
|
||||||
|
'password' => getenv('MYSQL_PASSWORD'),
|
||||||
|
'database' => getenv('MYSQL_DATABASE'),
|
||||||
|
],
|
||||||
|
'config' => [
|
||||||
|
'php_path' => '',
|
||||||
|
'hostname' => 'friendica.local',
|
||||||
|
'admin_email' => 'admin@philipp.info',
|
||||||
|
],
|
||||||
|
'system' => [
|
||||||
|
'urlpath' => 'test/it',
|
||||||
|
'url' => 'friendica.local/test/it',
|
||||||
|
'basepath' => '',
|
||||||
|
'ssl_policy' => '2',
|
||||||
|
'default_timezone' => 'en',
|
||||||
|
'language' => 'Europe/Berlin',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertFinished($txt, $withconfig = false, $copyfile = false)
|
private function assertFinished($txt, $withconfig = false, $copyfile = false)
|
||||||
|
@ -180,73 +208,24 @@ FIN;
|
||||||
$this->assertEquals($finished, $txt);
|
$this->assertEquals($finished, $txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataInstaller()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'empty' => [
|
|
||||||
'data' => [
|
|
||||||
'database' => [
|
|
||||||
'hostname' => '',
|
|
||||||
'username' => '',
|
|
||||||
'password' => '',
|
|
||||||
'database' => '',
|
|
||||||
],
|
|
||||||
'config' => [
|
|
||||||
'php_path' => '',
|
|
||||||
'hostname' => '',
|
|
||||||
'admin_email' => '',
|
|
||||||
],
|
|
||||||
'system' => [
|
|
||||||
'urlpath' => '',
|
|
||||||
'url' => '',
|
|
||||||
'basepath' => '',
|
|
||||||
'ssl_policy' => '',
|
|
||||||
'default_timezone' => '',
|
|
||||||
'language' => '',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'normal' => [
|
|
||||||
'data' => [
|
|
||||||
'database' => [
|
|
||||||
'hostname' => getenv('MYSQL_HOST'),
|
|
||||||
'port' =>!empty(getenv('MYSQL_PORT')) ? getenv('MYSQL_PORT') : null,
|
|
||||||
'username' => getenv('MYSQL_USERNAME'),
|
|
||||||
'password' => getenv('MYSQL_PASSWORD'),
|
|
||||||
'database' => getenv('MYSQL_DATABASE'),
|
|
||||||
],
|
|
||||||
'config' => [
|
|
||||||
'php_path' => '',
|
|
||||||
'hostname' => 'friendica.local',
|
|
||||||
'admin_email' => 'admin@philipp.info',
|
|
||||||
],
|
|
||||||
'system' => [
|
|
||||||
'urlpath' => 'test/it',
|
|
||||||
'url' => 'friendica.local/test/it',
|
|
||||||
'basepath' => '',
|
|
||||||
'ssl_policy' => '2',
|
|
||||||
'default_timezone' => 'en',
|
|
||||||
'language' => 'Europe/Berlin',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the automatic installation without any parameter
|
* Test the automatic installation without any parameter/setting
|
||||||
* @dataProvider dataInstaller
|
|
||||||
*/
|
*/
|
||||||
public function testEmpty(array $data)
|
public function testEmpty()
|
||||||
{
|
{
|
||||||
$configCache = new ConfigCache();
|
$configCache = new ConfigCache();
|
||||||
$configCache->load($data);
|
|
||||||
$configCache->set('system', 'basepath', $this->root->url());
|
$configCache->set('system', 'basepath', $this->root->url());
|
||||||
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
||||||
|
|
||||||
$this->mockApp($this->root, null, true);
|
$this->mockApp($this->root, null, true);
|
||||||
|
|
||||||
$this->configMock->shouldReceive('set');
|
$this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) use ($configCache) {
|
||||||
|
if ($key !== 'basepath') {
|
||||||
|
return $configCache->set($cat, $key, $value);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});;
|
||||||
$this->configMock->shouldReceive('has')->andReturn(true);
|
$this->configMock->shouldReceive('has')->andReturn(true);
|
||||||
$this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) use ($configCache) {
|
$this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) use ($configCache) {
|
||||||
return $configCache->get($cat, $key);
|
return $configCache->get($cat, $key);
|
||||||
|
@ -258,7 +237,7 @@ FIN;
|
||||||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||||
|
|
||||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||||
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro($configCache), '', 1);
|
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||||
|
|
||||||
$console = new AutomaticInstallation($this->consoleArgv);
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
|
@ -266,10 +245,26 @@ FIN;
|
||||||
|
|
||||||
$this->assertFinished($txt, true, false);
|
$this->assertFinished($txt, true, false);
|
||||||
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
|
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php'));
|
||||||
|
|
||||||
|
// Assert the default values without any config
|
||||||
|
$this->assertEquals(Installer::DEFAULT_HOST, $configCache->get('database', 'hostname'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'username'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'password'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'database'));
|
||||||
|
|
||||||
|
$this->assertEmpty($configCache->get('config', 'hostname'), $configCache->get('config', 'hostname'));
|
||||||
|
$this->assertEmpty($configCache->get('config', 'admin_email'), $configCache->get('config', 'admin_email'));
|
||||||
|
$this->assertEquals(trim(shell_exec('which php')), $configCache->get('config', 'php_path'));
|
||||||
|
|
||||||
|
$this->assertEquals(Installer::DEFAULT_TZ, $configCache->get('system', 'default_timezone'));
|
||||||
|
$this->assertEquals(Installer::DEFAULT_LANG, $configCache->get('system', 'language'));
|
||||||
|
$this->assertEquals(SSL_POLICY_NONE, $configCache->get('system', 'ssl_policy'));
|
||||||
|
$this->assertEmpty($configCache->get('system', 'urlpath'), $configCache->get('system', 'urlpath'));
|
||||||
|
$this->assertEquals($this->root->url(), $configCache->get('system', 'basepath'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* Test the automatic installation with a prepared config file
|
||||||
* @dataProvider dataInstaller
|
* @dataProvider dataInstaller
|
||||||
*/
|
*/
|
||||||
public function testWithConfig(array $data)
|
public function testWithConfig(array $data)
|
||||||
|
@ -348,7 +343,8 @@ CONF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* Test the automatic installation with environment variables
|
||||||
|
* Includes saving the DB credentials to the file
|
||||||
* @dataProvider dataInstaller
|
* @dataProvider dataInstaller
|
||||||
*/
|
*/
|
||||||
public function testWithEnvironmentAndSave(array $data)
|
public function testWithEnvironmentAndSave(array $data)
|
||||||
|
@ -357,7 +353,19 @@ CONF;
|
||||||
$configCache->set('system', 'basepath', $this->root->url());
|
$configCache->set('system', 'basepath', $this->root->url());
|
||||||
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
||||||
|
|
||||||
$this->mockApp($this->root, $configCache);
|
$this->mockApp($this->root, null, true);
|
||||||
|
|
||||||
|
$this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) use ($configCache) {
|
||||||
|
if ($key !== 'basepath') {
|
||||||
|
return $configCache->set($cat, $key, $value);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});;
|
||||||
|
$this->configMock->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) use ($configCache) {
|
||||||
|
return $configCache->get($cat, $key);
|
||||||
|
});
|
||||||
|
|
||||||
$this->mockConnect(true, 1);
|
$this->mockConnect(true, 1);
|
||||||
$this->mockConnected(true, 1);
|
$this->mockConnected(true, 1);
|
||||||
|
@ -365,81 +373,220 @@ CONF;
|
||||||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||||
|
|
||||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||||
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro($configCache), '', 1);
|
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||||
|
|
||||||
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=admin@friendica.local'));
|
$this->assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_TZ=Europe/Berlin'));
|
$this->assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
$this->assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
$this->assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
|
||||||
|
$this->assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
|
||||||
|
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_URL_PATH=' . $data['system']['urlpath']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_SSL_POLICY=' . $data['system']['ssl_policy']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
|
||||||
|
|
||||||
$console = new AutomaticInstallation($this->consoleArgv);
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
$console->setOption('savedb', true);
|
$console->setOption('savedb', true);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
print_r($configCache);
|
// Assert the default values without any config
|
||||||
|
$dbhost = $data['database']['hostname'] . (!empty($data['database']['port']) ? ':' . $data['database']['port'] : '');
|
||||||
|
$this->assertEquals($dbhost, $configCache->get('database', 'hostname'));
|
||||||
|
$this->assertEquals($data['database']['username'], $configCache->get('database', 'username'));
|
||||||
|
$this->assertEquals($data['database']['database'], $configCache->get('database', 'database'));
|
||||||
|
$this->assertEquals($data['database']['password'], $configCache->get('database', 'password'));
|
||||||
|
|
||||||
|
$this->assertEquals($data['config']['hostname'], $configCache->get('config', 'hostname'));
|
||||||
|
$this->assertEquals($data['config']['admin_email'], $configCache->get('config', 'admin_email'));
|
||||||
|
$this->assertEquals(trim(shell_exec('which php')), $configCache->get('config', 'php_path'));
|
||||||
|
|
||||||
|
$this->assertEquals((!empty($data['system']['default_timezone']) ? $data['system']['default_timezone'] : Installer::DEFAULT_TZ),
|
||||||
|
$configCache->get('system', 'default_timezone'));
|
||||||
|
$this->assertEquals((!empty($data['system']['language']) ? $data['system']['language'] : Installer::DEFAULT_LANG),
|
||||||
|
$configCache->get('system', 'language'));
|
||||||
|
$this->assertEquals((!empty($data['system']['ssl_policy']) ? $data['system']['ssl_policy'] : SSL_POLICY_NONE),
|
||||||
|
$configCache->get('system', 'ssl_policy'));
|
||||||
|
$this->assertEquals((!empty($data['system']['urlpath']) ? $data['system']['urlpath'] : null),
|
||||||
|
$configCache->get('system', 'urlpath'));
|
||||||
|
|
||||||
$this->assertFinished($txt, true);
|
$this->assertFinished($txt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* Test the automatic installation with environment variables
|
||||||
|
* Don't save the db credentials to the file
|
||||||
|
* @dataProvider dataInstaller
|
||||||
*/
|
*/
|
||||||
public function testWithEnvironmentWithoutSave()
|
public function testWithEnvironmentWithoutSave(array $data)
|
||||||
{
|
{
|
||||||
|
$configCache = new ConfigCache();
|
||||||
|
$configCache->set('system', 'basepath', $this->root->url());
|
||||||
|
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
||||||
|
|
||||||
|
$this->mockApp($this->root, null, true);
|
||||||
|
|
||||||
|
$this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) use ($configCache) {
|
||||||
|
if ($key !== 'basepath') {
|
||||||
|
return $configCache->set($cat, $key, $value);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});;
|
||||||
|
$this->configMock->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) use ($configCache) {
|
||||||
|
return $configCache->get($cat, $key);
|
||||||
|
});
|
||||||
|
|
||||||
$this->mockConnect(true, 1);
|
$this->mockConnect(true, 1);
|
||||||
$this->mockConnected(true, 1);
|
$this->mockConnected(true, 1);
|
||||||
$this->mockExistsTable('user', false, 1);
|
$this->mockExistsTable('user', false, 1);
|
||||||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||||
|
|
||||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||||
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(false), '', 1);
|
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||||
|
|
||||||
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=admin@friendica.local'));
|
$this->assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_TZ=Europe/Berlin'));
|
$this->assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_LANG=de'));
|
$this->assertTrue(putenv('MYSQL_DATABASE=' . $data['database']['database']));
|
||||||
$this->assertTrue(putenv('FRIENDICA_URL_PATH=/friendica'));
|
$this->assertTrue(putenv('MYSQL_USERNAME=' . $data['database']['username']));
|
||||||
|
$this->assertTrue(putenv('MYSQL_PASSWORD=' . $data['database']['password']));
|
||||||
|
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_URL_PATH=' . $data['system']['urlpath']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_BASE_PATH=' . $data['system']['basepath']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_PHP_PATH=' . $data['config']['php_path']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_SSL_POLICY=' . $data['system']['ssl_policy']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_HOSTNAME=' . $data['config']['hostname']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_ADMIN_MAIL=' . $data['config']['admin_email']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_TZ=' . $data['system']['default_timezone']));
|
||||||
|
$this->assertTrue(putenv('FRIENDICA_LANG=' . $data['system']['language']));
|
||||||
|
|
||||||
$console = new AutomaticInstallation($this->consoleArgv);
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
|
$this->assertEquals(Installer::DEFAULT_HOST, $configCache->get('database', 'hostname'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'username'), $configCache->get('database', 'username'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'password'), $configCache->get('database', 'password'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'database'), $configCache->get('database', 'database'));
|
||||||
|
|
||||||
|
$this->assertEquals($data['config']['hostname'], $configCache->get('config', 'hostname'));
|
||||||
|
$this->assertEquals($data['config']['admin_email'], $configCache->get('config', 'admin_email'));
|
||||||
|
$this->assertEquals(trim(shell_exec('which php')), $configCache->get('config', 'php_path'));
|
||||||
|
|
||||||
|
$this->assertEquals((!empty($data['system']['default_timezone']) ? $data['system']['default_timezone'] : Installer::DEFAULT_TZ),
|
||||||
|
$configCache->get('system', 'default_timezone'));
|
||||||
|
$this->assertEquals((!empty($data['system']['language']) ? $data['system']['language'] : Installer::DEFAULT_LANG),
|
||||||
|
$configCache->get('system', 'language'));
|
||||||
|
$this->assertEquals((!empty($data['system']['ssl_policy']) ? $data['system']['ssl_policy'] : SSL_POLICY_NONE),
|
||||||
|
$configCache->get('system', 'ssl_policy'));
|
||||||
|
$this->assertEquals((!empty($data['system']['urlpath']) ? $data['system']['urlpath'] : null),
|
||||||
|
$configCache->get('system', 'urlpath'));
|
||||||
|
|
||||||
$this->assertFinished($txt, true);
|
$this->assertFinished($txt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* Test the automatic installation with arguments
|
||||||
|
* @dataProvider dataInstaller
|
||||||
*/
|
*/
|
||||||
public function testWithArguments()
|
public function testWithArguments(array $data)
|
||||||
{
|
{
|
||||||
|
$configCache = new ConfigCache();
|
||||||
|
$configCache->set('system', 'basepath', $this->root->url());
|
||||||
|
$configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
||||||
|
|
||||||
|
$this->mockApp($this->root, null, true);
|
||||||
|
|
||||||
|
$this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) use ($configCache) {
|
||||||
|
if ($key !== 'basepath') {
|
||||||
|
return $configCache->set($cat, $key, $value);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});;
|
||||||
|
$this->configMock->shouldReceive('has')->andReturn(true);
|
||||||
|
$this->configMock->shouldReceive('get')->andReturnUsing(function ($cat, $key) use ($configCache) {
|
||||||
|
return $configCache->get($cat, $key);
|
||||||
|
});
|
||||||
|
|
||||||
$this->mockConnect(true, 1);
|
$this->mockConnect(true, 1);
|
||||||
$this->mockConnected(true, 1);
|
$this->mockConnected(true, 1);
|
||||||
$this->mockExistsTable('user', false, 1);
|
$this->mockExistsTable('user', false, 1);
|
||||||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||||
|
|
||||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||||
$this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(true), '', 1);
|
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||||
|
|
||||||
$console = new AutomaticInstallation($this->consoleArgv);
|
$console = new AutomaticInstallation($this->consoleArgv);
|
||||||
|
|
||||||
$console->setOption('dbhost', $this->db_host);
|
if (!empty($data['database']['hostname'])) {
|
||||||
$console->setOption('dbuser', $this->db_user);
|
$console->setOption('dbhost', $data['database']['hostname']);
|
||||||
if (!empty($this->db_pass)) {
|
|
||||||
$console->setOption('dbpass', $this->db_pass);
|
|
||||||
}
|
}
|
||||||
if (!empty($this->db_port)) {
|
if (!empty($data['database']['port'])) {
|
||||||
$console->setOption('dbport', $this->db_port);
|
$console->setOption('dbport', $data['database']['port']);
|
||||||
|
}
|
||||||
|
if (!empty($data['database']['username'])) {
|
||||||
|
$console->setOption('dbuser', $data['database']['username']);
|
||||||
|
}
|
||||||
|
if (!empty($data['database']['password'])) {
|
||||||
|
$console->setOption('dbpass', $data['database']['password']);
|
||||||
|
}
|
||||||
|
if (!empty($data['database']['database'])) {
|
||||||
|
$console->setOption('dbdata', $data['database']['database']);
|
||||||
|
}
|
||||||
|
if (!empty($data['system']['urlpath'])) {
|
||||||
|
$console->setOption('urlpath', $data['system']['urlpath']);
|
||||||
|
}
|
||||||
|
if (!empty($data['system']['basepath'])) {
|
||||||
|
$console->setOption('basepath', $data['system']['basepath']);
|
||||||
|
}
|
||||||
|
if (!empty($data['config']['php_path'])) {
|
||||||
|
$console->setOption('phppath', $data['config']['php_path']);
|
||||||
|
}
|
||||||
|
if (!empty($data['system']['ssl_policy'])) {
|
||||||
|
$console->setOption('sslpolicy', $data['system']['ssl_policy']);
|
||||||
|
}
|
||||||
|
if (!empty($data['config']['hostname'])) {
|
||||||
|
$console->setOption('hostname', $data['config']['hostname']);
|
||||||
|
}
|
||||||
|
if (!empty($data['config']['admin_email'])) {
|
||||||
|
$console->setOption('admin', $data['config']['admin_email']);
|
||||||
|
}
|
||||||
|
if (!empty($data['system']['default_timezone'])) {
|
||||||
|
$console->setOption('tz', $data['system']['default_timezone']);
|
||||||
|
}
|
||||||
|
if (!empty($data['system']['language'])) {
|
||||||
|
$console->setOption('lang', $data['system']['language']);
|
||||||
}
|
}
|
||||||
$console->setOption('dbdata', $this->db_data);
|
|
||||||
|
|
||||||
$console->setOption('admin', 'admin@friendica.local');
|
|
||||||
$console->setOption('tz', 'Europe/Berlin');
|
|
||||||
$console->setOption('lang', 'de');
|
|
||||||
|
|
||||||
$console->setOption('urlpath', '/friendica');
|
|
||||||
|
|
||||||
$txt = $this->dumpExecute($console);
|
$txt = $this->dumpExecute($console);
|
||||||
|
|
||||||
|
$dbhost = (!empty($data['database']['hostname'])) ? $data['database']['hostname'] : Installer::DEFAULT_HOST;
|
||||||
|
$dbhost .= (!empty($data['database']['port']) ? ':' . $data['database']['port'] : '');
|
||||||
|
$this->assertEquals($dbhost, $configCache->get('database', 'hostname'));
|
||||||
|
$this->assertEquals($data['database']['username'], $configCache->get('database', 'username'));
|
||||||
|
$this->assertEquals($data['database']['database'], $configCache->get('database', 'database'));
|
||||||
|
$this->assertEquals($data['database']['password'], $configCache->get('database', 'password'));
|
||||||
|
|
||||||
|
$this->assertEquals($data['config']['hostname'], $configCache->get('config', 'hostname'));
|
||||||
|
$this->assertEquals($data['config']['admin_email'], $configCache->get('config', 'admin_email'));
|
||||||
|
$this->assertEquals(trim(shell_exec('which php')), $configCache->get('config', 'php_path'));
|
||||||
|
|
||||||
|
$this->assertEquals((!empty($data['system']['default_timezone']) ? $data['system']['default_timezone'] : Installer::DEFAULT_TZ),
|
||||||
|
$configCache->get('system', 'default_timezone'));
|
||||||
|
$this->assertEquals((!empty($data['system']['language']) ? $data['system']['language'] : Installer::DEFAULT_LANG),
|
||||||
|
$configCache->get('system', 'language'));
|
||||||
|
$this->assertEquals((!empty($data['system']['ssl_policy']) ? $data['system']['ssl_policy'] : SSL_POLICY_NONE),
|
||||||
|
$configCache->get('system', 'ssl_policy'));
|
||||||
|
$this->assertEquals((!empty($data['system']['urlpath']) ? $data['system']['urlpath'] : null),
|
||||||
|
$configCache->get('system', 'urlpath'));
|
||||||
|
|
||||||
$this->assertFinished($txt, true);
|
$this->assertFinished($txt, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,10 +638,12 @@ Options
|
||||||
-d|--dbdata <database> The name of the mysql/mariadb database (env MYSQL_DATABASE)
|
-d|--dbdata <database> The name of the mysql/mariadb database (env MYSQL_DATABASE)
|
||||||
-U|--dbuser <username> The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
|
-U|--dbuser <username> The username of the mysql/mariadb database login (env MYSQL_USER or MYSQL_USERNAME)
|
||||||
-P|--dbpass <password> The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
|
-P|--dbpass <password> The password of the mysql/mariadb database login (env MYSQL_PASSWORD)
|
||||||
-u|--urlpath <url_path> The URL path of Friendica - f.e. '/friendica' (env FRIENDICA_URL_PATH)
|
-U|--urlpath <url_path> The URL path of Friendica - f.e. '/friendica' (env FRIENDICA_URL_PATH)
|
||||||
-b|--phppath <php_path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
-B|--phppath <php_path> The path of the PHP binary (env FRIENDICA_PHP_PATH)
|
||||||
-A|--admin <mail> The admin email address of Friendica (env FRIENDICA_ADMIN_MAIL)
|
-b|--basepath <base_path> The basepath of Friendica(env FRIENDICA_BASE_PATH)
|
||||||
-T|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
-S|--sslpolicy <ssl_policy> The SSL policy of Friendica (env FRIENDICA_SSL_POLICY)
|
||||||
|
-n|--hostname <hostname> The hostname of Friendica (env FRIENDICA_PHP_HOSTNAME)
|
||||||
|
-t|--tz <timezone> The timezone of Friendica (env FRIENDICA_TZ)
|
||||||
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
-L|--lang <language> The language of Friendica (env FRIENDICA_LANG)
|
||||||
|
|
||||||
Environment variables
|
Environment variables
|
||||||
|
@ -503,9 +652,12 @@ Environment variables
|
||||||
MYSQL_USERNAME|MYSQL_USER The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
|
MYSQL_USERNAME|MYSQL_USER The username of the mysql/mariadb database login (MYSQL_USERNAME is for mysql, MYSQL_USER for mariadb)
|
||||||
MYSQL_PASSWORD The password of the mysql/mariadb database login
|
MYSQL_PASSWORD The password of the mysql/mariadb database login
|
||||||
MYSQL_DATABASE The name of the mysql/mariadb database
|
MYSQL_DATABASE The name of the mysql/mariadb database
|
||||||
FRIENDICA_URL_PATH The URL path of Friendica (f.e. '/friendica')
|
FRIENDICA_URL_PATH The URL path of Friendica (f.e. '/friendica') - leave empty for auto detection
|
||||||
FRIENDICA_PHP_PATH The path of the PHP binary
|
FRIENDICA_PHP_PATH The path of the PHP binary - leave empty for auto detection
|
||||||
|
FRIENDICA_BASE_PATH The basepath of Friendica - leave empty for auto detection
|
||||||
FRIENDICA_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access)
|
FRIENDICA_ADMIN_MAIL The admin email address of Friendica (this email will be used for admin access)
|
||||||
|
FRIENDICA_SSL_POLICY The SSL policy of Friendica (default is NO SSL)
|
||||||
|
FRIENDICA_HOSTNAME The hostname of Friendica - leave empty for auto detection
|
||||||
FRIENDICA_TZ The timezone of Friendica
|
FRIENDICA_TZ The timezone of Friendica
|
||||||
FRIENDICA_LANG The langauge of Friendica
|
FRIENDICA_LANG The langauge of Friendica
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,6 @@ abstract class ConsoleTest extends MockedTest
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
if (!getenv('MYSQL_DATABASE')) {
|
|
||||||
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
|
|
||||||
}
|
|
||||||
|
|
||||||
Intercept::setUp();
|
Intercept::setUp();
|
||||||
|
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
Loading…
Reference in a new issue