]> git.mxchange.org Git - friendica.git/commitdiff
Fixed ConsoleTest
authorPhilipp Holzer <admin@philipp.info>
Mon, 11 Mar 2019 21:46:00 +0000 (22:46 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 23 Mar 2019 03:23:50 +0000 (23:23 -0400)
tests/Util/AppMockTrait.php
tests/src/Core/Console/AutomaticInstallationConsoleTest.php
tests/src/Core/Console/ConsoleTest.php

index 817570dd58c948cd4418e3217e4a660f3d6d1ac2..f8d154034670cdb1f789e06e0c593f7151980be6 100644 (file)
@@ -30,6 +30,11 @@ trait AppMockTrait
         */
        protected $profilerMock;
 
+       /**
+        * @var MockInterface|App\Mode The mocked App mode
+        */
+       protected $mode;
+
        /**
         * Mock the App
         *
@@ -38,6 +43,7 @@ trait AppMockTrait
        public function mockApp($root)
        {
                $this->configMock = \Mockery::mock(Config\Cache\IConfigCache::class);
+               $this->mode = \Mockery::mock(App\Mode::class);
                $configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class);
                // Disable the adapter
                $configAdapterMock->shouldReceive('isConnected')->andReturn(false);
@@ -52,6 +58,10 @@ trait AppMockTrait
                        ->shouldReceive('getBasePath')
                        ->andReturn($root->url());
 
+               $this->app
+                       ->shouldReceive('getMode')
+                       ->andReturn($this->mode);
+
                $this->configMock
                        ->shouldReceive('has')
                        ->andReturn(true);
index 73b6835fb5cce41a46731c4a800079a978beab1d..f806e6d7bb4f52fce940d449db1efb3b47e22087 100644 (file)
@@ -3,6 +3,7 @@
 namespace Friendica\Test\src\Core\Console;
 
 use Friendica\Core\Console\AutomaticInstallation;
+use Friendica\Core\Installer;
 use Friendica\Test\Util\DBAMockTrait;
 use Friendica\Test\Util\DBStructureMockTrait;
 use Friendica\Test\Util\L10nMockTrait;
@@ -55,6 +56,19 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
                $this->configMock
                        ->shouldReceive('get')
                        ->with('config', 'php_path')
+                       ->andReturn(null);
+
+               $this->configMock->shouldReceive('set')
+                       ->with('config', 'php_path', \Mockery::any())->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('config', 'hostname', '')->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('system', 'basepath', \Mockery::any())->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('system', 'urlpath' , '')->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('system', 'ssl_policy', SSL_POLICY_NONE)->once();
+               $this->mode->shouldReceive('isInstall')
                        ->andReturn(false);
 
                $this->mockL10nT();
@@ -75,9 +89,11 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
                        '$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'
                ];
 
@@ -176,6 +192,36 @@ FIN;
                $this->assertEquals($finished, $txt);
        }
 
+       /**
+        * Test the automatic installation without any parameter
+        */
+       public function testEmpty()
+       {
+               $this->mockConnect(true, 1);
+               $this->mockConnected(true, 1);
+               $this->mockExistsTable('user', false, 1);
+               $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
+
+               $this->configMock->shouldReceive('set')
+                       ->with('database', 'hostname', Installer::DEFAULT_HOST)->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('database', 'username', '')->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('database', 'password', '')->once();
+               $this->configMock->shouldReceive('set')
+                       ->with('database', 'database', '')->once();
+
+               $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
+               $this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
+
+               $console = new AutomaticInstallation($this->consoleArgv);
+
+               $txt = $this->dumpExecute($console);
+
+               $this->assertFinished($txt, false, true);
+
+       }
+
        /**
         * @medium
         */
index 4f7acc9c4229f62223b42cbdfca7121e46bffc81..bd821614f22e4da52d1d4942ece3edcf6ba70345 100644 (file)
@@ -30,6 +30,7 @@ abstract class ConsoleTest extends MockedTest
 
                $this->setUpVfsDir();
                $this->mockApp($this->root);
+
        }
 
        /**