]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/InstallerTest.php
Merge pull request #7072 from nupplaphil/task/mod_directory
[friendica.git] / tests / src / Core / InstallerTest.php
index f7f8f5c7d494834c2e4734d1a6e6c4768217ef52..a238bf8e7d9389383ef0bc3738163c2a694d0978 100644 (file)
@@ -3,9 +3,13 @@
 // this is in the same namespace as Install for mocking 'function_exists'
 namespace Friendica\Core;
 
+use Friendica\Core\Config\Cache\IConfigCache;
+use Friendica\Network\CurlResult;
+use Friendica\Object\Image;
 use Friendica\Test\MockedTest;
 use Friendica\Test\Util\L10nMockTrait;
 use Friendica\Test\Util\VFSTrait;
+use Friendica\Util\Network;
 
 /**
  * @runTestsInSeparateProcesses
@@ -45,6 +49,8 @@ class InstallerTest extends MockedTest
                $this->mockL10nT('Error: POSIX PHP module required but not installed.', 1);
                $this->mockL10nT('JSON PHP module', 1);
                $this->mockL10nT('Error: JSON PHP module required but not installed.', 1);
+               $this->mockL10nT('File Information PHP module', 1);
+               $this->mockL10nT('Error: File Information PHP module required but not installed.', 1);
        }
 
        private function assertCheckExist($position, $title, $help, $status, $required, $assertionArray)
@@ -192,6 +198,17 @@ class InstallerTest extends MockedTest
                        true,
                        $install->getChecks());
 
+               $this->mockFunctionL10TCalls();
+               $this->setFunctions(['finfo_open' => false]);
+               $install = new Installer();
+               $this->assertFalse($install->checkFunctions());
+               $this->assertCheckExist(10,
+                       'File Information PHP module',
+                       'Error: File Information PHP module required but not installed.',
+                       false,
+                       true,
+                       $install->getChecks());
+
                $this->mockFunctionL10TCalls();
                $this->setFunctions([
                        'curl_init' => true,
@@ -200,7 +217,8 @@ class InstallerTest extends MockedTest
                        'mb_strlen' => true,
                        'iconv_strlen' => true,
                        'posix_kill' => true,
-                       'json_encode' => true
+                       'json_encode' => true,
+                       'finfo_open' => true,
                ]);
                $install = new Installer();
                $this->assertTrue($install->checkFunctions());
@@ -234,7 +252,7 @@ class InstallerTest extends MockedTest
                $this->mockL10nT();
 
                // Mocking the CURL Response
-               $curlResult = \Mockery::mock('Friendica\Network\CurlResult');
+               $curlResult = \Mockery::mock(CurlResult::class);
                $curlResult
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
@@ -246,7 +264,7 @@ class InstallerTest extends MockedTest
                        ->andReturn('test Error');
 
                // Mocking the CURL Request
-               $networkMock = \Mockery::mock('alias:Friendica\Util\Network');
+               $networkMock = \Mockery::mock('alias:' . Network::class);
                $networkMock
                        ->shouldReceive('fetchUrlFull')
                        ->with('https://test/install/testrewrite')
@@ -273,19 +291,19 @@ class InstallerTest extends MockedTest
                $this->mockL10nT();
 
                // Mocking the failed CURL Response
-               $curlResultF = \Mockery::mock('Friendica\Network\CurlResult');
+               $curlResultF = \Mockery::mock(CurlResult::class);
                $curlResultF
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
 
                // Mocking the working CURL Response
-               $curlResultW = \Mockery::mock('Friendica\Network\CurlResult');
+               $curlResultW = \Mockery::mock(CurlResult::class);
                $curlResultW
                        ->shouldReceive('getReturnCode')
                        ->andReturn('204');
 
                // Mocking the CURL Request
-               $networkMock = \Mockery::mock('alias:Friendica\Util\Network');
+               $networkMock = \Mockery::mock('alias:' . Network::class);
                $networkMock
                        ->shouldReceive('fetchUrlFull')
                        ->with('https://test/install/testrewrite')
@@ -313,7 +331,7 @@ class InstallerTest extends MockedTest
        {
                $this->mockL10nT();
 
-               $imageMock = \Mockery::mock('alias:Friendica\Object\Image');
+               $imageMock = \Mockery::mock('alias:'. Image::class);
                $imageMock
                        ->shouldReceive('supportedTypes')
                        ->andReturn(['image/gif' => 'gif']);
@@ -340,7 +358,7 @@ class InstallerTest extends MockedTest
        {
                $this->mockL10nT();
 
-               $imageMock = \Mockery::mock('alias:Friendica\Object\Image');
+               $imageMock = \Mockery::mock('alias:' . Image::class);
                $imageMock
                        ->shouldReceive('supportedTypes')
                        ->andReturn([]);
@@ -375,6 +393,21 @@ class InstallerTest extends MockedTest
                        false,
                        $install->getChecks());
        }
+
+       /**
+        * Test the setup of the config cache for installation
+        */
+       public function testSetUpCache()
+       {
+               $this->mockL10nT();
+
+               $install = new Installer();
+               $configCache = \Mockery::mock(IConfigCache::class);
+               $configCache->shouldReceive('set')->with('config', 'php_path', \Mockery::any())->once();
+               $configCache->shouldReceive('set')->with('system', 'basepath', '/test/')->once();
+
+               $install->setUpCache($configCache, '/test/');
+       }
 }
 
 /**