Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
tools: composer:v2

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Download dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.16.4
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [3.1.2] - 2025-11-11

- Allow PHPUnit > 9
- Removed PhpUnitBackwardCompatibleTrait

## [3.1.1] - 2024-09-01

- Switched to `httpbin.org` for tests now that its fixed. (Reverts [#56](https://github.com/php-http/client-integration-tests/pull/56))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"phpunit/phpunit": "^9.6.17",
"phpunit/phpunit": "^9.6.17 || ^10.0 || ^11.0 || ^12.0",
"php-http/message": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0",
"guzzlehttp/psr7": "^1.9 || ^2.0",
Expand Down
17 changes: 12 additions & 5 deletions src/HttpAsyncClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Http\Client\Tests;

use Http\Client\HttpAsyncClient;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;

abstract class HttpAsyncClientTest extends HttpBaseTest
{
Expand Down Expand Up @@ -33,8 +35,8 @@ public function testSuccessiveCallMustUseResponseInterface()
{
$request = self::$messageFactory->createRequest(
'GET',
$this->getUri(),
$this->defaultHeaders
self::getUri(),
self::$defaultHeaders
);

$promise = $this->httpAsyncClient->sendAsyncRequest($request);
Expand All @@ -61,7 +63,7 @@ public function testSuccessiveInvalidCallMustUseException()
$request = self::$messageFactory->createRequest(
'GET',
$this->getInvalidUri(),
$this->defaultHeaders
self::$defaultHeaders
);

$promise = $this->httpAsyncClient->sendAsyncRequest($request);
Expand Down Expand Up @@ -90,6 +92,8 @@ public function testSuccessiveInvalidCallMustUseException()
* @dataProvider requestProvider
* @group integration
*/
#[DataProvider('requestProvider')]
#[Group('integration')]
public function testAsyncSendRequest($method, $uri, array $headers, $body)
{
if (null != $body) {
Expand Down Expand Up @@ -124,14 +128,15 @@ public function testAsyncSendRequest($method, $uri, array $headers, $body)
}

/**
* @group integration
* @group integration
*/
#[Group('integration')]
public function testSendAsyncWithInvalidUri()
{
$request = self::$messageFactory->createRequest(
'GET',
$this->getInvalidUri(),
$this->defaultHeaders
self::$defaultHeaders
);

$exception = null;
Expand Down Expand Up @@ -159,6 +164,8 @@ public function testSendAsyncWithInvalidUri()
* @dataProvider requestWithOutcomeProvider
* @group integration
*/
#[Group('integration')]
#[DataProvider('requestWithOutcomeProvider')]
public function testSendAsyncRequestWithOutcome($uriAndOutcome, $protocolVersion, array $headers, $body)
{
if ('1.0' === $protocolVersion) {
Expand Down
52 changes: 25 additions & 27 deletions src/HttpBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

abstract class HttpBaseTest extends TestCase
{
use PhpUnitBackwardCompatibleTrait;

/**
* @var string
*/
Expand All @@ -36,7 +34,7 @@ abstract class HttpBaseTest extends TestCase
/**
* @var array
*/
protected $defaultHeaders = [
protected static $defaultHeaders = [
'Connection' => 'close',
'User-Agent' => 'PHP HTTP Adapter',
'Content-Length' => '0',
Expand All @@ -61,13 +59,13 @@ public static function tearDownAfterClass(): void
}
}

public function requestProvider(): array
public static function requestProvider(): array
{
$sets = [
'methods' => $this->getMethods(),
'uris' => [$this->getUri()],
'headers' => $this->getHeaders(),
'body' => $this->getBodies(),
'methods' => self::getMethods(),
'uris' => [self::getUri()],
'headers' => self::getHeaders(),
'body' => self::getBodies(),
];

$cartesianProduct = new CartesianProduct($sets);
Expand All @@ -84,21 +82,21 @@ public function requestProvider(): array
});
}

public function requestWithOutcomeProvider(): array
public static function requestWithOutcomeProvider(): array
{
$sets = [
'urisAndOutcomes' => $this->getUrisAndOutcomes(),
'protocolVersions' => $this->getProtocolVersions(),
'headers' => $this->getHeaders(),
'body' => $this->getBodies(),
'urisAndOutcomes' => self::getUrisAndOutcomes(),
'protocolVersions' => self::getProtocolVersions(),
'headers' => self::getHeaders(),
'body' => self::getBodies(),
];

$cartesianProduct = new CartesianProduct($sets);

return $cartesianProduct->compute();
}

private function getMethods(): array
private static function getMethods(): array
{
return [
'GET',
Expand All @@ -116,7 +114,7 @@ private function getMethods(): array
*
* @return string|null
*/
protected function getUri(array $query = [])
protected static function getUri(array $query = [])
{
return !empty($query)
? PHPUnitUtility::getUri().'?'.http_build_query($query, '', '&')
Expand All @@ -134,25 +132,25 @@ protected function getInvalidUri()
/**
* @return array
*/
private function getUrisAndOutcomes()
private static function getUrisAndOutcomes()
{
return [
[
$this->getUri(['client_error' => true]),
self::getUri(['client_error' => true]),
[
'statusCode' => 400,
'reasonPhrase' => 'Bad Request',
],
],
[
$this->getUri(['server_error' => true]),
self::getUri(['server_error' => true]),
[
'statusCode' => 500,
'reasonPhrase' => 'Internal Server Error',
],
],
[
$this->getUri(['redirect' => true]),
self::getUri(['redirect' => true]),
[
'statusCode' => 302,
'reasonPhrase' => 'Found',
Expand All @@ -165,41 +163,41 @@ private function getUrisAndOutcomes()
/**
* @return array
*/
private function getProtocolVersions()
private static function getProtocolVersions()
{
return ['1.1', '1.0'];
}

/**
* @return string[]
*/
private function getHeaders()
private static function getHeaders()
{
$headers = $this->defaultHeaders;
$headers = self::$defaultHeaders;
$headers['Accept-Charset'] = 'utf-8';
$headers['Accept-Language'] = 'en';

return [
$this->defaultHeaders,
self::$defaultHeaders,
$headers,
];
}

/**
* @return array
*/
private function getBodies()
private static function getBodies()
{
return [
null,
http_build_query($this->getData(), '', '&'),
http_build_query(self::getData(), '', '&'),
];
}

/**
* @return array
*/
private function getData()
private static function getData()
{
return ['param1' => 'foo', 'param2' => ['bar', ['baz']]];
}
Expand All @@ -223,7 +221,7 @@ protected function assertResponse(ResponseInterface $response, array $options =
if (null === $options['body']) {
$this->assertEmpty($response->getBody()->__toString());
} else {
$this->assertStringContainsString($options['body'], $response->getBody()->__toString());
self::assertStringContainsString($options['body'], $response->getBody()->__toString());
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Http\Client\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Client\NetworkExceptionInterface;

Expand Down Expand Up @@ -37,6 +39,8 @@ abstract protected function createHttpAdapter(): ClientInterface;
* @dataProvider requestProvider
* @group integration
*/
#[Group('integration')]
#[DataProvider('requestProvider')]
public function testSendRequest($method, $uri, array $headers, $body)
{
if (null != $body) {
Expand Down Expand Up @@ -65,6 +69,8 @@ public function testSendRequest($method, $uri, array $headers, $body)
* @dataProvider requestWithOutcomeProvider
* @group integration
*/
#[Group('integration')]
#[DataProvider('requestWithOutcomeProvider')]
public function testSendRequestWithOutcome($uriAndOutcome, $protocolVersion, array $headers, $body)
{
if ('1.0' === $protocolVersion) {
Expand Down Expand Up @@ -95,12 +101,13 @@ public function testSendRequestWithOutcome($uriAndOutcome, $protocolVersion, arr
/**
* @group integration
*/
#[Group('integration')]
public function testSendWithInvalidUri()
{
$request = self::$messageFactory->createRequest(
'GET',
$this->getInvalidUri(),
$this->defaultHeaders
self::$defaultHeaders
);

$this->expectException(NetworkExceptionInterface::class);
Expand Down
2 changes: 0 additions & 2 deletions src/HttpFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

abstract class HttpFeatureTest extends TestCase
{
use PhpUnitBackwardCompatibleTrait;

/**
* @var MessageFactory
*/
Expand Down
18 changes: 0 additions & 18 deletions src/PhpUnitBackwardCompatibleTrait.php

This file was deleted.

Loading