Skip to content

Commit 768040c

Browse files
committed
Fix CI tests and add recent PHP versions to matrix
1 parent 725165c commit 768040c

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

Diff for: .github/workflows/continuous-integration.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ jobs:
4848
- "7.4"
4949
- "8.0"
5050
- "8.1"
51+
- "8.2"
52+
- "8.3"
5153
dependencies:
5254
- "lowest"
5355
- "highest"
5456

5557
steps:
5658
- name: "Checkout repository"
57-
uses: "actions/checkout@v2"
59+
uses: "actions/checkout@v4"
5860

5961
- name: "Install PHP"
6062
uses: "shivammathur/setup-php@v2"
@@ -63,10 +65,10 @@ jobs:
6365
coverage: "none"
6466

6567
- name: "Install dependencies (Composer)"
66-
uses: "ramsey/composer-install@v2"
68+
uses: "ramsey/composer-install@v3"
6769
with:
6870
dependency-versions: "${{ matrix.dependencies }}"
6971

7072
- name: "Run unit tests (PHPUnit)"
7173
shell: "bash"
72-
run: "vendor/bin/simple-phpunit"
74+
run: "vendor/bin/phpunit"

Diff for: composer.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
"require": {
2020
"php": ">=7.4",
2121
"php-http/client-common": ">=1.3",
22-
"symfony/rate-limiter": ">=5.2"
22+
"symfony/rate-limiter": ">=5.4"
2323
},
2424
"require-dev": {
2525
"nyholm/psr7": "^1.0",
26-
"php-http/mock-client": "*",
26+
"php-http/mock-client": "^1.4",
2727
"ramsey/coding-standard": "^2.0",
28-
"symfony/phpunit-bridge": ">=6.0"
28+
"symfony/phpunit-bridge": ">=6.0",
29+
"phpunit/phpunit": "^9.6",
30+
"psr/http-factory": "^1.1"
2931
},
3032
"minimum-stability": "dev",
3133
"prefer-stable": true,
@@ -42,7 +44,8 @@
4244
"config": {
4345
"allow-plugins": {
4446
"dealerdirect/phpcodesniffer-composer-installer": true,
45-
"ergebnis/composer-normalize": true
47+
"ergebnis/composer-normalize": true,
48+
"php-http/discovery": true
4649
}
4750
}
4851
}

Diff for: phpcs.xml.dist

+2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
<arg value="sp"/>
77

88
<file>./src</file>
9+
<file>./tests</file>
910

1011
<rule ref="Ramsey">
1112
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName"/>
13+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBeforeDeclare"/>
1214
</rule>
1315

1416
</ruleset>

Diff for: phpunit.xml.dist

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="./vendor/bin/.phpunit/phpunit/phpunit.xsd"
4-
bootstrap="./vendor/autoload.php"
5-
colors="true"
6-
verbose="true">
7-
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
5+
colors="true"
6+
bootstrap="./vendor/autoload.php"
7+
>
88
<php>
99
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
1010
</php>
1111

12+
<listeners>
13+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
14+
</listeners>
15+
1216
<testsuites>
1317
<testsuite name="unit-tests">
14-
<directory>./src</directory>
18+
<directory>tests</directory>
1519
</testsuite>
1620
</testsuites>
1721

Diff for: src/ThrottlePlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(LimiterInterface $rateLimiter, int $tokens = 1, ?flo
3232
}
3333

3434
/**
35-
* @throws MaxWaitDurationExceededException if $maxTime is set and the process needs to wait longer than its value (in seconds)
35+
* @throws MaxWaitDurationExceededException if $maxTime is set and the process needs to wait longer than its value
3636
* @throws ReserveNotSupportedException if this limiter implementation doesn't support reserving tokens
3737
* @throws InvalidArgumentException if $tokens is larger than the maximum burst size
3838
*/

Diff for: tests/ThrottlePluginTest.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Http\Client\Common\Plugin\ThrottlePlugin;
88
use Http\Client\Common\PluginClient;
99
use Http\Mock\Client;
10-
use Nyholm\Psr7\Factory\HttplugFactory;
10+
use Nyholm\Psr7\Factory\Psr17Factory;
1111
use Nyholm\Psr7\Request;
1212
use PHPUnit\Framework\TestCase;
1313
use Symfony\Bridge\PhpUnit\ClockMock;
@@ -27,7 +27,7 @@ class ThrottlePluginTest extends TestCase
2727
protected function setUp(): void
2828
{
2929
ClockMock::register(RateLimit::class);
30-
$this->mockClient = new Client(new HttplugFactory());
30+
$this->mockClient = new Client(new Psr17Factory());
3131
$this->client = new PluginClient($this->mockClient, [
3232
new ThrottlePlugin(
3333
(new RateLimiterFactory(
@@ -83,7 +83,7 @@ public function testMaxTime(): void
8383
{
8484
$this->client = new PluginClient($this->mockClient, [
8585
new ThrottlePlugin(
86-
$rateLimit = (new RateLimiterFactory(
86+
(new RateLimiterFactory(
8787
['id' => 'foo', 'policy' => 'fixed_window', 'limit' => 2, 'interval' => '3 seconds'],
8888
new InMemoryStorage(),
8989
))->create(),
@@ -93,7 +93,9 @@ public function testMaxTime(): void
9393
]);
9494

9595
$this->expectException(MaxWaitDurationExceededException::class);
96-
$this->expectExceptionMessage('The rate limiter wait time ("3" seconds) is longer than the provided maximum time ("1" seconds).');
96+
$this->expectExceptionMessage(
97+
'The rate limiter wait time ("3" seconds) is longer than the provided maximum time ("1" seconds).',
98+
);
9799

98100
$time = time();
99101
$this->client->sendRequest(new Request('GET', ''));

0 commit comments

Comments
 (0)