]> git.mxchange.org Git - friendica.git/commitdiff
Bugfixing AutomaticInstallation test
authorPhilipp Holzer <admin@philipp.info>
Sun, 3 Feb 2019 23:04:16 +0000 (00:04 +0100)
committerPhilipp Holzer <admin@philipp.info>
Sun, 3 Feb 2019 23:04:16 +0000 (00:04 +0100)
src/Core/Console/AutomaticInstallation.php
src/Core/Console/Config.php
src/Core/Console/Typo.php
tests/Util/AppMockTrait.php
tests/src/BaseObjectTest.php
tests/src/Core/Cache/CacheTest.php
tests/src/Core/Console/AutomaticInstallationConsoleTest.php
tests/src/Core/Console/ConsoleTest.php
tests/src/Core/Lock/LockTest.php

index 8c3e5ebbeeae7dc15c734baca733b81f063cdae5..da078545e3eb0dd4c52c98ab0f329ca83fc1dd59 100644 (file)
@@ -100,10 +100,10 @@ HELP;
                                }
                        }
 
-                       $db_host = Config::getConfigValue('database', 'hostname');
-                       $db_user = Config::getConfigValue('database', 'username');
-                       $db_pass = Config::getConfigValue('database', 'password');
-                       $db_data = Config::getConfigValue('database', 'database');
+                       $db_host = $a->getConfig()->get('database', 'hostname');
+                       $db_user = $a->getConfig()->get('database', 'username');
+                       $db_pass = $a->getConfig()->get('database', 'password');
+                       $db_data = $a->getConfig()->get('database', 'database');
                } else {
                        // Creating config file
                        $this->out("Creating config file...\n");
index 8a0e0f88cf4930511a49c6f180a218a024930a2c..c72e26906f23e5237331d4dce3df1e056bd23190 100644 (file)
@@ -124,9 +124,9 @@ HELP;
                        $cat = $this->getArgument(0);
                        Core\Config::load($cat);
 
-                       if (Core\Config::getConfigValue($cat) !== null) {
+                       if ($a->getConfig()->get($cat) !== null) {
                                $this->out("[{$cat}]");
-                               $catVal = Core\Config::getConfigValue($cat);
+                               $catVal = $a->getConfig()->get($cat);
                                foreach ($catVal as $key => $value) {
                                        if (is_array($value)) {
                                                foreach ($value as $k => $v) {
@@ -148,7 +148,7 @@ HELP;
                                $this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
                        }
 
-                       $config = Core\Config::getAll();
+                       $config = $a->getConfig()->getAll();
                        foreach ($config as $cat => $section) {
                                if (is_array($section)) {
                                        foreach ($section as $key => $value) {
index 3f9dce84e055a19db0eb98c7830331fb80830de6..32ba6ded35186878bea79e9bf8cac456c8444172 100644 (file)
@@ -2,6 +2,8 @@
 
 namespace Friendica\Core\Console;
 
+use Friendica\BaseObject;
+
 /**
  * Tired of chasing typos and finding them after a commit.
  * Run this and quickly see if we've got any parse errors in our application files.
@@ -41,7 +43,7 @@ HELP;
                        throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
                }
 
-               $php_path = \Friendica\Core\Config::getConfigValue('config', 'php_path', 'php');
+               $php_path = BaseObject::getApp()->getConfig()->get('config', 'php_path', 'php');
 
                if ($this->getOption('v')) {
                        $this->out('Directory: src');
index c6793218446cc168bc01e9628b822e98609ff108..290191cba125b6e40fca01d5d1a8f279e9e459da 100644 (file)
@@ -4,6 +4,7 @@ namespace Friendica\Test\Util;
 
 use Friendica\App;
 use Friendica\BaseObject;
+use Friendica\Core\Config\ConfigCache;
 use Friendica\Render\FriendicaSmartyEngine;
 use Mockery\MockInterface;
 use org\bovigo\vfs\vfsStreamDirectory;
@@ -24,8 +25,9 @@ trait AppMockTrait
         * Mock the App
         *
         * @param vfsStreamDirectory $root The root directory
+        * @param MockInterface|ConfigCache $config The config cache
         */
-       public function mockApp($root)
+       public function mockApp($root, $config)
        {
                $this->mockConfigGet('system', 'theme', 'testtheme');
 
@@ -35,22 +37,26 @@ trait AppMockTrait
                        ->shouldReceive('getBasePath')
                        ->andReturn($root->url());
 
-               $this->app
-                       ->shouldReceive('getConfigValue')
+               $config
+                       ->shouldReceive('get')
                        ->with('database', 'hostname')
                        ->andReturn(getenv('MYSQL_HOST'));
-               $this->app
-                       ->shouldReceive('getConfigValue')
+               $config
+                       ->shouldReceive('get')
                        ->with('database', 'username')
                        ->andReturn(getenv('MYSQL_USERNAME'));
-               $this->app
-                       ->shouldReceive('getConfigValue')
+               $config
+                       ->shouldReceive('get')
                        ->with('database', 'password')
                        ->andReturn(getenv('MYSQL_PASSWORD'));
-               $this->app
-                       ->shouldReceive('getConfigValue')
+               $config
+                       ->shouldReceive('get')
                        ->with('database', 'database')
                        ->andReturn(getenv('MYSQL_DATABASE'));
+               $this->app
+                       ->shouldReceive('getConfig')
+                       ->andReturn($config);
+
                $this->app
                        ->shouldReceive('getTemplateEngine')
                        ->andReturn(new FriendicaSmartyEngine());
index 2b10556af67d79885342b3f05e88f698b4294ff1..2dbf5580f61ffc7106afe6af302394ceb95d0bba 100644 (file)
@@ -32,7 +32,8 @@ class BaseObjectTest extends TestCase
        protected function setUp()
        {
                $this->setUpVfsDir();
-               $this->mockApp($this->root);
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
 
                $this->baseObject = new BaseObject();
        }
index b9a22ee9ca375ac8c0495fa67af77e9b817cee6d..d0b357bf465dad6a77768cb9fc9ec48110b6c763 100644 (file)
@@ -69,7 +69,8 @@ abstract class CacheTest extends MockedTest
        protected function setUp()
        {
                $this->setUpVfsDir();
-               $this->mockApp($this->root);
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
                $this->app
                        ->shouldReceive('getHostname')
                        ->andReturn('friendica.local');
index 361608d375f3f06f0b1564c4e402768de6cc3afe..127a8bc3f87bdf38fdd4228de33925b1ec94f91f 100644 (file)
@@ -181,7 +181,7 @@ FIN;
                $this->mockConnect(true, 1);
                $this->mockConnected(true, 1);
                $this->mockExistsTable('user', false, 1);
-               $this->mockUpdate([false, true, true], null, 1);
+               $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $config = <<<CONF
 <?php
@@ -241,7 +241,7 @@ CONF;
                $this->mockConnect(true, 1);
                $this->mockConnected(true, 1);
                $this->mockExistsTable('user', false, 1);
-               $this->mockUpdate([false, true, true], null, 1);
+               $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
                $this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(true), '', 1);
@@ -267,7 +267,7 @@ CONF;
                $this->mockConnect(true, 1);
                $this->mockConnected(true, 1);
                $this->mockExistsTable('user', false, 1);
-               $this->mockUpdate([false, true, true], null, 1);
+               $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
                $this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(false), '', 1);
@@ -292,7 +292,7 @@ CONF;
                $this->mockConnect(true, 1);
                $this->mockConnected(true, 1);
                $this->mockExistsTable('user', false, 1);
-               $this->mockUpdate([false, true, true], null, 1);
+               $this->mockUpdate([$this->root->url(), false, true, true], null, 1);
 
                $this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
                $this->mockReplaceMacros('testTemplate', $this->createArgumentsForMacro(true), '', 1);
index 4f7acc9c4229f62223b42cbdfca7121e46bffc81..905d214cac2b6282ceb298c5c5a391d3073d0587 100644 (file)
@@ -29,7 +29,8 @@ abstract class ConsoleTest extends MockedTest
                Intercept::setUp();
 
                $this->setUpVfsDir();
-               $this->mockApp($this->root);
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
        }
 
        /**
index 320beb3054e2f95638bdf6ec88f801d5124852e0..2d11a71ae18946c153d726f0c56833d881914995 100644 (file)
@@ -31,7 +31,8 @@ abstract class LockTest extends MockedTest
 
                // Reusable App object
                $this->setUpVfsDir();
-               $this->mockApp($this->root);
+               $configMock = \Mockery::mock('Friendica\Core\Config\ConfigCache');
+               $this->mockApp($this->root, $configMock);
                $this->app
                        ->shouldReceive('getHostname')
                        ->andReturn('friendica.local');