Skip to content

Commit

Permalink
Move method check to function.
Browse files Browse the repository at this point in the history
  • Loading branch information
srmklive committed Nov 5, 2023
1 parent dadc0b0 commit 1a88106
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/MockClientClasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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' : '';
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 1a88106

Please sign in to comment.