]> git.mxchange.org Git - friendica.git/commitdiff
Fixed ConfigConsoleTest
authorPhilipp Holzer <admin@philipp.info>
Wed, 13 Mar 2019 20:51:04 +0000 (21:51 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 23 Mar 2019 03:25:22 +0000 (23:25 -0400)
tests/src/Core/Console/AutomaticInstallationConsoleTest.php
tests/src/Core/Console/ConfigConsoleTest.php
tests/src/Core/Console/ConsoleTest.php

index f806e6d7bb4f52fce940d449db1efb3b47e22087..925b122b435a7217e3bc6c3e194ce3d6df82a6c7 100644 (file)
@@ -2,6 +2,7 @@
 
 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;
@@ -53,24 +54,6 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
                $this->db_user = getenv('MYSQL_USERNAME') . getenv('MYSQL_USER');
                $this->db_pass = getenv('MYSQL_PASSWORD');
 
-               $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();
        }
 
@@ -192,25 +175,51 @@ FIN;
                $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()
+       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->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);
 
@@ -218,14 +227,18 @@ FIN;
 
                $txt = $this->dumpExecute($console);
 
-               $this->assertFinished($txt, false, true);
+               $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);
index ef50c19b7271a895acf592486522fb990810facf..c8deda55557e9da8a4962119bfbc62beb26099aa 100644 (file)
@@ -16,6 +16,8 @@ class ConfigConsoleTest extends ConsoleTest
        {
                parent::setUp();
 
+               $this->mockApp($this->root);
+
                \Mockery::getConfiguration()->setConstantsMap([
                        Mode::class => [
                                'DBCONFIGAVAILABLE' => 0
index bd821614f22e4da52d1d4942ece3edcf6ba70345..4fc44b92c5b5f2ec8a2eddc7f60579ad79120e60 100644 (file)
@@ -29,8 +29,6 @@ abstract class ConsoleTest extends MockedTest
                Intercept::setUp();
 
                $this->setUpVfsDir();
-               $this->mockApp($this->root);
-
        }
 
        /**