]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Console/AutomaticInstallationConsoleTest.php
Merge remote-tracking branch 'upstream/develop' into aria
[friendica.git] / tests / src / Console / AutomaticInstallationConsoleTest.php
index bdc38bbf30444314195019f98e6e4b66ec3a3f48..774db31746fd5d94f1fa4e629df7c31ea8f24334 100644 (file)
@@ -2,25 +2,27 @@
 
 namespace Friendica\Test\src\Console;
 
+use Dice\Dice;
+use Friendica\App;
+use Friendica\BaseObject;
 use Friendica\Console\AutomaticInstallation;
 use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Core\Installer;
+use Friendica\Core\L10n\L10n;
 use Friendica\Core\Logger;
+use Friendica\Database\Database;
 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;
 
-/**
- * @requires PHP 7.0
- */
 class AutomaticInstallationConsoleTest extends ConsoleTest
 {
-       use L10nMockTrait;
+       use VFSTrait;
        use DBAMockTrait;
        use DBStructureMockTrait;
        use RendererMockTrait;
@@ -39,26 +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);
+
+               BaseObject::setDependencyInjection($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);
        }