]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/InstallerTest.php
Fixing some AutomaticInstallationConsoleTests
[friendica.git] / tests / src / Core / InstallerTest.php
index ebbf5037d4b780ff464209ea130536bd92aa4ec7..e56596c6c090b67fc0574d9c0041d74723173da9 100644 (file)
@@ -3,9 +3,12 @@
 // this is in the same namespace as Install for mocking 'function_exists'
 namespace Friendica\Core;
 
+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
@@ -43,6 +46,10 @@ class InstallerTest extends MockedTest
                $this->mockL10nT('Error: iconv PHP module required but not installed.', 1);
                $this->mockL10nT('POSIX PHP module', 1);
                $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)
@@ -97,6 +104,8 @@ class InstallerTest extends MockedTest
         */
        public function testCheckKeys()
        {
+               $this->mockL10nT();
+
                $this->setFunctions(['openssl_pkey_new' => false]);
                $install = new Installer();
                $this->assertFalse($install->checkKeys());
@@ -177,6 +186,28 @@ class InstallerTest extends MockedTest
                        true,
                        $install->getChecks());
 
+               $this->mockFunctionL10TCalls();
+               $this->setFunctions(['json_encode' => false]);
+               $install = new Installer();
+               $this->assertFalse($install->checkFunctions());
+               $this->assertCheckExist(9,
+                       'JSON PHP module',
+                       'Error: JSON PHP module required but not installed.',
+                       false,
+                       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,
@@ -184,7 +215,9 @@ class InstallerTest extends MockedTest
                        'openssl_public_encrypt' => true,
                        'mb_strlen' => true,
                        'iconv_strlen' => true,
-                       'posix_kill' => true
+                       'posix_kill' => true,
+                       'json_encode' => true,
+                       'finfo_open' => true,
                ]);
                $install = new Installer();
                $this->assertTrue($install->checkFunctions());
@@ -195,14 +228,16 @@ class InstallerTest extends MockedTest
         */
        public function testCheckLocalIni()
        {
-               $this->assertTrue($this->root->hasChild('config/local.ini.php'));
+               $this->mockL10nT();
+
+               $this->assertTrue($this->root->hasChild('config/local.config.php'));
 
                $install = new Installer();
                $this->assertTrue($install->checkLocalIni());
 
-               $this->delConfigFile('local.ini.php');
+               $this->delConfigFile('local.config.php');
 
-               $this->assertFalse($this->root->hasChild('config/local.ini.php'));
+               $this->assertFalse($this->root->hasChild('config/local.config.php'));
 
                $install = new Installer();
                $this->assertTrue($install->checkLocalIni());
@@ -213,8 +248,10 @@ class InstallerTest extends MockedTest
         */
        public function testCheckHtAccessFail()
        {
+               $this->mockL10nT();
+
                // Mocking the CURL Response
-               $curlResult = \Mockery::mock('Friendica\Network\CurlResult');
+               $curlResult = \Mockery::mock(CurlResult::class);
                $curlResult
                        ->shouldReceive('getReturnCode')
                        ->andReturn('404');
@@ -226,7 +263,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')
@@ -239,9 +276,6 @@ class InstallerTest extends MockedTest
                // Mocking that we can use CURL
                $this->setFunctions(['curl_init' => true]);
 
-               // needed because of "normalise_link"
-               require_once __DIR__ . '/../../../include/text.php';
-
                $install = new Installer();
 
                $this->assertFalse($install->checkHtAccess('https://test'));
@@ -253,20 +287,22 @@ class InstallerTest extends MockedTest
         */
        public function testCheckHtAccessWork()
        {
+               $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')
@@ -292,7 +328,9 @@ class InstallerTest extends MockedTest
         */
        public function testImagick()
        {
-               $imageMock = \Mockery::mock('alias:Friendica\Object\Image');
+               $this->mockL10nT();
+
+               $imageMock = \Mockery::mock('alias:'. Image::class);
                $imageMock
                        ->shouldReceive('supportedTypes')
                        ->andReturn(['image/gif' => 'gif']);
@@ -317,7 +355,9 @@ class InstallerTest extends MockedTest
         */
        public function testImagickNotFound()
        {
-               $imageMock = \Mockery::mock('alias:Friendica\Object\Image');
+               $this->mockL10nT();
+
+               $imageMock = \Mockery::mock('alias:' . Image::class);
                $imageMock
                        ->shouldReceive('supportedTypes')
                        ->andReturn([]);