<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Core;
use Dice\Dice;
-use Friendica\Core\Config\Cache;
+use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
+use Friendica\Core\Config\ValueObject\Cache;
use Friendica\DI;
-use Friendica\Network\IHTTPResult;
-use Friendica\Network\IHTTPClient;
+use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
+use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
use Mockery;
class InstallerTest extends MockedTest
{
use VFSTrait;
+ use ArraySubsetAsserts;
/**
* @var L10n|MockInterface
->with(L10n::class)
->andReturn($this->l10nMock);
- DI::init($this->dice);
+ DI::init($this->dice, true);
}
public static function tearDownAfterClass(): void
$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);
+ $this->mockL10nT('GNU Multiple Precision PHP module', 1);
+ $this->mockL10nT('Error: GNU Multiple Precision PHP module required but not installed.', 1);
$this->mockL10nT('Program execution functions', 1);
$this->mockL10nT('Error: Program execution functions (proc_open) required but not enabled.', 1);
}
true,
$install->getChecks());
+ $this->mockFunctionL10TCalls();
+ $this->setFunctions(['gmp_strval' => false]);
+ $install = new Installer();
+ self::assertFalse($install->checkFunctions());
+ self::assertCheckExist(12,
+ 'GNU Multiple Precision PHP module',
+ 'Error: GNU Multiple Precision PHP module required but not installed.',
+ false,
+ true,
+ $install->getChecks());
+
$this->mockFunctionL10TCalls();
$this->setFunctions([
'curl_init' => true,
'posix_kill' => true,
'json_encode' => true,
'finfo_open' => true,
+ 'gmp_strval' => true,
]);
$install = new Installer();
self::assertTrue($install->checkFunctions());
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
// Mocking the CURL Response
- $IHTTPResult = Mockery::mock(IHTTPResult::class);
+ $IHTTPResult = Mockery::mock(ICanHandleHttpResponses::class);
$IHTTPResult
->shouldReceive('getReturnCode')
->andReturn('404');
->andReturn('test Error');
// Mocking the CURL Request
- $networkMock = Mockery::mock(IHTTPClient::class);
+ $networkMock = Mockery::mock(ICanSendHttpRequests::class);
$networkMock
->shouldReceive('fetchFull')
->with('https://test/install/testrewrite')
->andReturn($IHTTPResult);
$this->dice->shouldReceive('create')
- ->with(IHTTPClient::class)
+ ->with(ICanSendHttpRequests::class)
->andReturn($networkMock);
- DI::init($this->dice);
+ DI::init($this->dice, true);
// Mocking that we can use CURL
$this->setFunctions(['curl_init' => true]);
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
// Mocking the failed CURL Response
- $IHTTPResultF = Mockery::mock(IHTTPResult::class);
+ $IHTTPResultF = Mockery::mock(ICanHandleHttpResponses::class);
$IHTTPResultF
->shouldReceive('getReturnCode')
->andReturn('404');
// Mocking the working CURL Response
- $IHTTPResultW = Mockery::mock(IHTTPResult::class);
+ $IHTTPResultW = Mockery::mock(ICanHandleHttpResponses::class);
$IHTTPResultW
->shouldReceive('getReturnCode')
->andReturn('204');
// Mocking the CURL Request
- $networkMock = Mockery::mock(IHTTPClient::class);
+ $networkMock = Mockery::mock(ICanSendHttpRequests::class);
$networkMock
->shouldReceive('fetchFull')
->with('https://test/install/testrewrite')
->andReturn($IHTTPResultW);
$this->dice->shouldReceive('create')
- ->with(IHTTPClient::class)
+ ->with(ICanSendHttpRequests::class)
->andReturn($networkMock);
- DI::init($this->dice);
+ DI::init($this->dice, true);
// Mocking that we can use CURL
$this->setFunctions(['curl_init' => true]);