diff --git a/tests/MockClientClasses.php b/tests/MockClientClasses.php index 317343f9..109fe3fe 100644 --- a/tests/MockClientClasses.php +++ b/tests/MockClientClasses.php @@ -30,10 +30,7 @@ private function mock_http_client($response): HttpClient private function mock_http_request($expectedResponse, $expectedEndpoint, $expectedParams, $expectedMethod = 'post') { - $set_method_name = 'setMethods'; - if (strpos(phpversion(), '8.1') !== false || strpos(phpversion(), '8.2') !== false || strpos(phpversion(), '8.3') !== false) { - $set_method_name = 'onlyMethods'; - } + $set_method_name = ($this->setMethodsFunction() === true) ? 'onlyMethods' : 'setMethods'; $mockResponse = $this->getMockBuilder(ResponseInterface::class) ->getMock(); @@ -54,13 +51,7 @@ private function mock_http_request($expectedResponse, $expectedEndpoint, $expect private function mock_client($expectedResponse, $expectedMethod, $token = false, $additionalMethod = null) { - $set_method_name = 'setMethods'; - - foreach (['8.1', '8.2', '8.3'] as $php_version) { - if (strpos(phpversion(), $php_version) !== false) { - $set_method_name = 'onlyMethods'; - } - } + $set_method_name = ($this->setMethodsFunction() === true) ? 'onlyMethods' : 'setMethods'; $methods = [$expectedMethod, 'setApiCredentials']; $methods[] = ($token) ? 'getAccessToken' : ''; @@ -123,4 +114,17 @@ private function getApiCredentials(): array 'validate_ssl' => true, ]; } + + protected function setMethodsFunction(): bool + { + $useOnlyMethods = false; + + foreach (['8.1', '8.2', '8.3'] as $php_version) { + if (strpos(phpversion(), $php_version) !== false) { + $useOnlyMethods = true; + } + } + + return $useOnlyMethods; + } }