Skip to content

Commit a2cceef

Browse files
authored
Merge pull request #483 from php-http/sf8
test with symfony 8
2 parents c68dd70 + f15537a commit a2cceef

File tree

12 files changed

+67
-34
lines changed

12 files changed

+67
-34
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ jobs:
7272
symfony-require: "7.4.*"
7373
php-version: "8.5"
7474
symfony-deprecations-helper: "weak"
75+
- dependencies: "php-http/guzzle7-adapter symfony/http-client:^8"
76+
symfony-require: "8.0.*"
77+
php-version: "8.5"
78+
symfony-deprecations-helper: "weak"
7579

7680
steps:
7781
- name: "Checkout"
@@ -88,14 +92,21 @@ jobs:
8892
tools: "flex"
8993

9094
- name: "Enforce using stable dependencies"
91-
run: "composer config minimum-stability stable"
92-
if: "${{ matrix.stability == 'stable' }}"
95+
run: "composer config minimum-stability ${{ matrix.stability }}"
96+
if: "${{ matrix.stability }}"
9397

9498
- name: "Add dependencies and enable flex"
9599
run: |
96100
composer config allow-plugins.symfony/flex true
97101
composer require --no-update ${{ matrix.dependencies }}
98102
103+
- name: "Work around https://github.com/symfony/symfony/pull/62692"
104+
run: "composer require --no-update symfony/console:*"
105+
106+
- name: "Get correct version for workaround"
107+
run: "composer require --no-update symfony/console:${{ matrix.symfony-require }}"
108+
if: "${{ matrix.symfony-require }}"
109+
99110
- name: "Install dependencies with Composer"
100111
uses: "ramsey/composer-install@v3"
101112
with:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
44

55
# Version 2
66

7+
# 2.3.0 - unreleased
8+
9+
- Compatible with Symfony 8.
10+
711
# 2.2.0 - 2025-12-11
812

913
- Replaced XML configuration with PHP configuration.

composer.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
"php-http/stopwatch-plugin": "^1.2",
3636
"psr/http-factory-implementation": "^1.0",
3737
"psr/http-message": "^1.0 || ^2.0",
38-
"symfony/config": "^6.4 || ^7.1",
39-
"symfony/dependency-injection": "^6.4 || ^7.1",
40-
"symfony/event-dispatcher": "^6.4 || ^7.1",
41-
"symfony/http-kernel": "^6.4 || ^7.1",
42-
"symfony/options-resolver": "^6.4 || ^7.1"
38+
"symfony/config": "^6.4 || ^7.1 || ^8.0",
39+
"symfony/dependency-injection": "^6.4 || ^7.1 || ^8.0",
40+
"symfony/event-dispatcher": "^6.4 || ^7.1 || ^8.0",
41+
"symfony/http-kernel": "^6.4 || ^7.1 || ^8.0",
42+
"symfony/options-resolver": "^6.4 || ^7.1 || ^8.0"
4343
},
4444
"conflict": {
4545
"kriswallsmith/buzz": "<0.17",
@@ -52,23 +52,23 @@
5252
},
5353
"require-dev": {
5454
"guzzlehttp/psr7": "^1.7 || ^2.0",
55-
"matthiasnoback/symfony-config-test": "^5.2",
56-
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
55+
"matthiasnoback/symfony-config-test": "^5.2 || ^v6.1.0",
56+
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0 || ^6.2.0",
5757
"nyholm/nsa": "^1.1",
5858
"nyholm/psr7": "^1.2.1",
59-
"php-http/cache-plugin": "^1.7",
59+
"php-http/cache-plugin": "^1.7 || ^2.0",
6060
"php-http/mock-client": "^1.2",
6161
"php-http/promise": "^1.0",
6262
"php-http/throttle-plugin": "^1.1",
63-
"phpunit/phpunit": "^9",
64-
"symfony/browser-kit": "^6.4 || ^7.1",
65-
"symfony/cache": "^6.4 || ^7.1",
66-
"symfony/dom-crawler": "^6.4 || ^7.1",
67-
"symfony/framework-bundle": "^6.4 || ^7.1",
68-
"symfony/http-foundation": "^6.4 || ^7.1",
69-
"symfony/stopwatch": "^6.4 || ^7.1",
70-
"symfony/twig-bundle": "^6.4 || ^7.1",
71-
"symfony/web-profiler-bundle": "^6.4 || ^7.1",
63+
"phpunit/phpunit": "^9 || ^10.0 || ^11.0 || ^12.0",
64+
"symfony/browser-kit": "^6.4 || ^7.1 || ^8.0",
65+
"symfony/cache": "^6.4 || ^7.1 || ^8.0",
66+
"symfony/dom-crawler": "^6.4 || ^7.1 || ^8.0",
67+
"symfony/framework-bundle": "^6.4 || ^7.1 || ^8.0",
68+
"symfony/http-foundation": "^6.4 || ^7.1 || ^8.0",
69+
"symfony/stopwatch": "^6.4 || ^7.1 || ^8.0",
70+
"symfony/twig-bundle": "^6.4 || ^7.1 || ^8.0",
71+
"symfony/web-profiler-bundle": "^6.4 || ^7.1 || ^8.0",
7272
"twig/twig": "^1.41 || ^2.10 || ^3.0"
7373
},
7474
"suggest": {
@@ -96,7 +96,6 @@
9696
"tests/Resources/app/AppKernel.php"
9797
]
9898
},
99-
"prefer-stable": false,
10099
"scripts": {
101100
"test": "vendor/bin/phpunit",
102101
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"

src/Collector/Collector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
final class Collector extends DataCollector
2323
{
2424
private ?Stack $activeStack = null;
25+
private ?int $capturedBodyLength = null;
2526

26-
public function __construct(private ?int $capturedBodyLength = null)
27+
public function __construct(?int $capturedBodyLength = null)
2728
{
29+
$this->capturedBodyLength = $capturedBodyLength;
2830
$this->reset();
2931
}
3032

tests/Functional/DiscoveredClientsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Nyholm\NSA;
1616
use Psr\Http\Client\ClientInterface;
1717
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
18+
use Symfony\Component\DependencyInjection\ContainerInterface;
1819

1920
final class DiscoveredClientsTest extends WebTestCase
2021
{
@@ -119,7 +120,7 @@ public function testForcedDiscovery(): void
119120
$this->assertEquals($container->get('httplug.client.acme'), HttpAsyncClientDiscovery::find());
120121
}
121122

122-
private function getCustomContainer($debug, $environment = 'test')
123+
private function getCustomContainer($debug, $environment = 'test'): ContainerInterface
123124
{
124125
static::bootKernel(['debug' => $debug, 'environment' => $environment]);
125126

tests/Functional/Issue206.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Http\HttplugBundle\Tests\Functional;
66

77
use Http\Client\Common\HttpMethodsClient;
8-
use Http\Client\Common\PluginClient;
98
use Http\Client\Common\PluginClientFactory;
109
use Http\Discovery\Psr18ClientDiscovery;
1110
use Nyholm\Psr7\Factory\Psr17Factory;
@@ -24,6 +23,6 @@ public function testCustomClientDoesNotCauseException(): void
2423
$pluginClient = (new PluginClientFactory())->createClient($myCustomClient, []);
2524

2625
// If we get to this line, no exceptions has been thrown.
27-
$this->assertInstanceOf(PluginClient::class, $pluginClient);
26+
$this->addToAssertionCount(1);
2827
}
2928
}

tests/Functional/ProfilerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\Tests\Functional;
66

77
use GuzzleHttp\Psr7\Request;
8+
use PHPUnit\Framework\Attributes\Group;
89
use Psr\Http\Client\ClientInterface;
910
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1011

@@ -13,6 +14,7 @@ final class ProfilerTest extends WebTestCase
1314
/**
1415
* @group legacy
1516
*/
17+
#[Group('legacy')]
1618
public function testShowProfiler(): void
1719
{
1820
$client = static::createClient();

tests/Functional/ProfilingTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
use GuzzleHttp\Psr7\Request;
88
use Http\Client\Common\Plugin;
99
use Http\Client\Common\PluginClient;
10-
use Http\Discovery\StreamFactoryDiscovery;
11-
use Http\Discovery\UriFactoryDiscovery;
10+
use Http\Discovery\Psr17FactoryDiscovery;
1211
use Http\HttplugBundle\Collector\Collector;
1312
use Http\HttplugBundle\Collector\Formatter;
1413
use Http\HttplugBundle\Collector\ProfileClient;
@@ -40,7 +39,7 @@ public function setUp(): void
4039
public function testProfilingWithCachePlugin(): void
4140
{
4241
$client = $this->createClient([
43-
new Plugin\CachePlugin(new ArrayAdapter(), StreamFactoryDiscovery::find(), [
42+
new Plugin\CachePlugin(new ArrayAdapter(), Psr17FactoryDiscovery::findStreamFactory(), [
4443
'respect_response_cache_directives' => [],
4544
'default_ttl' => 86400,
4645
]),
@@ -79,7 +78,7 @@ public function testProfilingWhenPluginThrowException(): void
7978
public function testProfiling(): void
8079
{
8180
$client = $this->createClient([
82-
new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri('https://example.com')),
81+
new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://example.com')),
8382
new Plugin\RedirectPlugin(),
8483
new Plugin\RetryPlugin(),
8584
]);
@@ -95,7 +94,7 @@ public function testProfiling(): void
9594
$this->assertEquals('example.com', $stack->getRequestHost());
9695
}
9796

98-
private function createClient(array $plugins, $clientName = 'Acme', array $clientOptions = [])
97+
private function createClient(array $plugins, string $clientName = 'Acme', array $clientOptions = [])
9998
{
10099
$plugins = array_map(fn (Plugin $plugin) => new ProfilePlugin($plugin, $this->collector, $this->formatter, $plugin::class), $plugins);
101100

tests/Functional/ServiceInstantiationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Http\HttplugBundle\Collector\ProfilePlugin;
1414
use Http\HttplugBundle\Collector\StackPlugin;
1515
use Nyholm\NSA;
16+
use PHPUnit\Framework\Attributes\Group;
1617
use Psr\Http\Client\ClientInterface;
1718
use Psr\Http\Message\ResponseInterface;
1819
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -55,6 +56,7 @@ public function testHttpClientNoDebug(): void
5556
/**
5657
* @group legacy
5758
*/
59+
#[Group('legacy')]
5860
public function testDebugToolbar(): void
5961
{
6062
static::bootKernel(['debug' => true]);

tests/Unit/Collector/FormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Http\Message\Formatter as MessageFormatter;
1313
use Http\Message\Formatter\CurlCommandFormatter;
1414
use Http\Message\Formatter\SimpleFormatter;
15+
use PHPUnit\Framework\Attributes\Group;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718

@@ -66,6 +67,7 @@ public function testFormatResponseForRequest(): void
6667
/**
6768
* @group legacy
6869
*/
70+
#[Group('legacy')]
6971
public function testFormatResponse(): void
7072
{
7173
$response = new Response();

0 commit comments

Comments
 (0)