]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Console/AutomaticInstallationConsoleTest.php
Merge pull request #8134 from nupplaphil/task/di_l10n
[friendica.git] / tests / src / Console / AutomaticInstallationConsoleTest.php
index 5ea349f8b136010babc7b34de024d26f27872d4a..ab879b31945095be535403f5cfb6a44cc25e0aae 100644 (file)
@@ -2,27 +2,27 @@
 
 namespace Friendica\Test\src\Console;
 
+use Dice\Dice;
+use Friendica\App;
 use Friendica\Console\AutomaticInstallation;
 use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Core\Installer;
+use Friendica\Core\L10n;
 use Friendica\Core\Logger;
+use Friendica\Database\Database;
+use Friendica\DI;
 use Friendica\Test\Util\DBAMockTrait;
 use Friendica\Test\Util\DBStructureMockTrait;
-use Friendica\Test\Util\L10nMockTrait;
 use Friendica\Test\Util\RendererMockTrait;
-use Friendica\Util\BaseURL;
+use Friendica\Test\Util\VFSTrait;
 use Friendica\Util\Logger\VoidLogger;
+use Mockery\MockInterface;
 use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\vfsStreamFile;
 
-/**
- * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
- * @requires PHP 7.0
- */
 class AutomaticInstallationConsoleTest extends ConsoleTest
 {
-       use L10nMockTrait;
+       use VFSTrait;
        use DBAMockTrait;
        use DBStructureMockTrait;
        use RendererMockTrait;
@@ -41,24 +41,49 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
         */
        private $configCache;
 
+       /**
+        * @var App\Mode
+        */
+       private $appMode;
+
+       /**
+        * @var Database
+        */
+       private $dba;
+
+       /**
+        * @var Dice|MockInterface
+        */
+       private $dice;
+
        public function setUp()
        {
+               $this->markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
+
                parent::setUp();
 
+               $this->setUpVfsDir();;
+
                if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
                        $this->root->getChild('config')
                                ->removeChild('local.config.php');
                }
+               $this->dice = \Mockery::mock(Dice::class)->makePartial();
 
-               $this->mockL10nT();
+               $l10nMock = \Mockery::mock(L10n::class);
+               $l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
+
+               $this->dice->shouldReceive('create')
+                          ->with(L10n::class)
+                          ->andReturn($l10nMock);
+
+               DI::init($this->dice);
 
                $this->configCache = new ConfigCache();
                $this->configCache->set('system', 'basepath', $this->root->url());
                $this->configCache->set('config', 'php_path', trim(shell_exec('which php')));
                $this->configCache->set('system', 'theme', 'smarty3');
 
-               $this->mockApp($this->root, true);
-
                $this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) {
                        if ($key !== 'basepath') {
                                return $this->configCache->set($cat, $key, $value);
@@ -72,7 +97,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
                        return $this->configCache->get($cat, $key);
                });
                $this->configMock->shouldReceive('load')->andReturnUsing(function ($config, $overwrite = false) {
-                       return $this->configCache->load($config, $overwrite);
+                       $this->configCache->load($config, $overwrite);
                });
 
                $this->mode->shouldReceive('isInstall')->andReturn(true);
@@ -327,7 +352,7 @@ FIN;
                $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', 'ssl_policy', $assertion, ($default) ? App\BaseURL::DEFAULT_SSL_SCHEME : null);
                $this->assertConfigEntry('system', 'basepath', ($realBasepath) ? $this->root->url() : $assertion);
        }
 
@@ -356,7 +381,7 @@ FIN;
                $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
-               $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
 
                $console = new AutomaticInstallation($this->consoleArgv);
                $console->setOption('url', 'http://friendica.local');
@@ -392,7 +417,7 @@ FIN;
 
 // Local configuration
 
-// If you're unsure about what any of the config keys below do, please check the config/defaults.config.php for detailed
+// If you're unsure about what any of the config keys below do, please check the static/defaults.config.php for detailed
 // documentation of their data type and behavior.
 
 return [
@@ -458,7 +483,7 @@ CONF;
                $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
-               $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
 
                $this->assertTrue(putenv('MYSQL_HOST='     . $data['database']['hostname']));
                $this->assertTrue(putenv('MYSQL_PORT='     . $data['database']['port']));
@@ -496,7 +521,7 @@ CONF;
                $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
-               $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
 
                $this->assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
                $this->assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
@@ -532,7 +557,7 @@ CONF;
                $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
-               $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
 
                $console = new AutomaticInstallation($this->consoleArgv);
 
@@ -567,7 +592,7 @@ CONF;
                $this->mockConnect(false, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
-               $this->mockReplaceMacros('testTemplate', \Mockery::any(), false, '', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
 
                $console = new AutomaticInstallation($this->consoleArgv);
                $console->setOption('url', 'http://friendica.local');