Skip to content

Commit

Permalink
Test against 8.4
Browse files Browse the repository at this point in the history
Required >= 7.3
Update guzzle dependencies
Update phpunit config
Fix parsing of account balance object
Fix wrong body parsing in SuccessfulResponseParsingException
  • Loading branch information
nickdnk committed Feb 5, 2025
1 parent d0d0eaa commit 8b92bc8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v2
- run: mkdir -p build/logs
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
vendor/
.phpunit.result.cache
.phpunit.result.cache
composer.lock
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.0.0 - 2025-02-05
* Require at least PHP 7.3.
* Test against PHP 8.4.
* Dropped support for Guzzle 6 (now requires Guzzle 7).
* Updated requirements for `guzzlehttp/oauth-subscriber` to minimum `0.8.1` to address [CVE-2025-21617](https://nvd.nist.gov/vuln/detail/CVE-2025-21617).

## 3.3.1 - 2024-09-02
* Test against PHP 8.3.
* Round the total cost of messages to 5 decimal points.
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"description": "PHP library based on Guzzle for integration with gatewayapi.com",
"type": "library",
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.3 || ^8.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"guzzlehttp/oauth-subscriber": "0.3.* || 0.4.* || 0.5.* || 0.6.*"
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/oauth-subscriber": "~0.8.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"php-coveralls/php-coveralls": "^v2.5.2"
"phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^v2.7.0"
},
"license": "mit",
"authors": [
Expand Down
38 changes: 17 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false"
bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false"
stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src/</directory>
</include>
<exclude>
<file>./src/Exceptions/ConnectionException.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Test">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<file>./src/Exceptions/ConnectionException.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
<logging/>
</phpunit>
2 changes: 1 addition & 1 deletion src/Entities/Constructable.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function constructFromResponse(ResponseInterface $response)
} catch (InvalidArgumentException $exception) {

throw new SuccessfulResponseParsingException(
'Failed to construct \'' . static::class . '\' from: ' . json_encode($response->getBody()), $response
'Failed to construct \'' . static::class . '\' from: ' . $response->getBody(), $response
);

}
Expand Down
6 changes: 3 additions & 3 deletions src/Entities/Response/AccountBalance.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ public function getId(): int
public static function constructFromArray(array $array): AccountBalance
{

// Apparently credit is now a string, but used to be a float.
if (array_key_exists('credit', $array)
&& array_key_exists('currency', $array)
&& array_key_exists('id', $array)
&& is_float($array['credit'])
&& (is_float($array['credit']) || is_string($array['credit']))
&& is_string($array['currency'])
&& is_integer($array['id'])) {

return new AccountBalance($array['credit'], $array['currency'], $array['id']);
return new AccountBalance((float)$array['credit'], $array['currency'], $array['id']);

}

throw new InvalidArgumentException('Array passed to ' . self::class . ' is missing required parameters.');

}
}

2 changes: 1 addition & 1 deletion tests/AccountBalanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testConstructFromResponse()
$response = new Response(
200, [], json_encode(
[
'credit' => 1453.55,
'credit' => '1453.55',
'currency' => 'eur',
'id' => 1232323
]
Expand Down

0 comments on commit 8b92bc8

Please sign in to comment.