X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fsrc%2FCore%2FInstallerTest.php;h=9256581b16ce8e8031a5a356a5b7aa68740c4a60;hb=15bc1ac8a18924551c8af772c07e5fed9c75023b;hp=0933d9e1a52b608c876354f31abb68692d29fbd7;hpb=feabf80476313b91d3ef41a5a60b5585c7f415ee;p=friendica.git diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php index 0933d9e1a5..9256581b16 100644 --- a/tests/src/Core/InstallerTest.php +++ b/tests/src/Core/InstallerTest.php @@ -1,6 +1,6 @@ dice); } + public static function tearDownAfterClass(): void + { + // Reset mocking + global $phpMock; + $phpMock = []; + + parent::tearDownAfterClass(); + } + private function mockL10nT(string $text, $times = null) { $this->l10nMock->shouldReceive('t')->with($text)->andReturn($text)->times($times); @@ -93,6 +104,8 @@ class InstallerTest extends MockedTest $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('Program execution functions', 1); + $this->mockL10nT('Error: Program execution functions (proc_open) required but not enabled.', 1); } private function assertCheckExist($position, $title, $help, $status, $required, $assertionArray) @@ -232,10 +245,20 @@ class InstallerTest extends MockedTest $install->getChecks()); $this->mockFunctionL10TCalls(); - $this->setFunctions(['json_encode' => false]); + $this->setFunctions(['proc_open' => false]); $install = new Installer(); self::assertFalse($install->checkFunctions()); self::assertCheckExist(9, + 'Program execution functions', + 'Error: Program execution functions (proc_open) required but not enabled.', + false, + true, + $install->getChecks()); + $this->mockFunctionL10TCalls(); + $this->setFunctions(['json_encode' => false]); + $install = new Installer(); + self::assertFalse($install->checkFunctions()); + self::assertCheckExist(10, 'JSON PHP module', 'Error: JSON PHP module required but not installed.', false, @@ -246,7 +269,7 @@ class InstallerTest extends MockedTest $this->setFunctions(['finfo_open' => false]); $install = new Installer(); self::assertFalse($install->checkFunctions()); - self::assertCheckExist(10, + self::assertCheckExist(11, 'File Information PHP module', 'Error: File Information PHP module required but not installed.', false, @@ -298,30 +321,30 @@ class InstallerTest extends MockedTest $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); // Mocking the CURL Response - $curlResult = Mockery::mock(CurlResult::class); - $curlResult + $IHTTPResult = Mockery::mock(ICanHandleHttpResponses::class); + $IHTTPResult ->shouldReceive('getReturnCode') ->andReturn('404'); - $curlResult + $IHTTPResult ->shouldReceive('getRedirectUrl') ->andReturn(''); - $curlResult + $IHTTPResult ->shouldReceive('getError') ->andReturn('test Error'); // Mocking the CURL Request - $networkMock = Mockery::mock(IHTTPRequest::class); + $networkMock = Mockery::mock(ICanSendHttpRequests::class); $networkMock ->shouldReceive('fetchFull') ->with('https://test/install/testrewrite') - ->andReturn($curlResult); + ->andReturn($IHTTPResult); $networkMock ->shouldReceive('fetchFull') ->with('http://test/install/testrewrite') - ->andReturn($curlResult); + ->andReturn($IHTTPResult); $this->dice->shouldReceive('create') - ->with(IHTTPRequest::class) + ->with(ICanSendHttpRequests::class) ->andReturn($networkMock); DI::init($this->dice); @@ -345,30 +368,30 @@ class InstallerTest extends MockedTest $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); // Mocking the failed CURL Response - $curlResultF = Mockery::mock(CurlResult::class); - $curlResultF + $IHTTPResultF = Mockery::mock(ICanHandleHttpResponses::class); + $IHTTPResultF ->shouldReceive('getReturnCode') ->andReturn('404'); // Mocking the working CURL Response - $curlResultW = Mockery::mock(CurlResult::class); - $curlResultW + $IHTTPResultW = Mockery::mock(ICanHandleHttpResponses::class); + $IHTTPResultW ->shouldReceive('getReturnCode') ->andReturn('204'); // Mocking the CURL Request - $networkMock = Mockery::mock(IHTTPRequest::class); + $networkMock = Mockery::mock(ICanSendHttpRequests::class); $networkMock ->shouldReceive('fetchFull') ->with('https://test/install/testrewrite') - ->andReturn($curlResultF); + ->andReturn($IHTTPResultF); $networkMock ->shouldReceive('fetchFull') ->with('http://test/install/testrewrite') - ->andReturn($curlResultW); + ->andReturn($IHTTPResultW); $this->dice->shouldReceive('create') - ->with(IHTTPRequest::class) + ->with(ICanSendHttpRequests::class) ->andReturn($networkMock); DI::init($this->dice); @@ -451,6 +474,7 @@ class InstallerTest extends MockedTest /** * Test the setup of the config cache for installation + * @doesNotPerformAssertions */ public function testSetUpCache() {