Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Symfony HttpClient implementation for v6.* and PHP to 8.0 #96

Merged
merged 7 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 1 addition & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
composer-opts:
Expand Down Expand Up @@ -66,10 +64,7 @@ jobs:

# https://github.com/php-coveralls/php-coveralls#github-actions
- name: Upload coverage results to Coveralls
# NOTE: For now we would run this step only on php7.4 due to the error on php8.
# https://github.com/ackintosh/ganesha/runs/4375377952?check_suite_focus=true
# > PHP Fatal error: Declaration of PhpCoveralls\Bundle\CoverallsBundle\Console\Application::getDefinition() must be compatible with ...
if: ${{ matrix.php-version == '7.4' }}
if: ${{ matrix.php-version == '8.0' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": ">=7.3.0",
"php": ">=8.0",
"psr/http-message": "~1.0"
},
"suggest": {
Expand All @@ -29,11 +29,11 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
"symfony/http-client": "^4.3|^5.0",
"symfony/yaml": "^3.0|^4.0|^5.0",
"symfony/http-client": "^5.3|^6.0",
"symfony/yaml": "^3.0|^4.0|^5.0|^6.0",
"php-vcr/php-vcr": "^1.4.5",
"php-vcr/phpunit-testlistener-vcr": "dev-php8 as 3.2.2",
"php-coveralls/php-coveralls": "~2.0",
"php-coveralls/php-coveralls": "~2.5",
"predis/predis": "^1.1",
"guzzlehttp/guzzle": "~6.5",
"friendsofphp/php-cs-fixer": "^v3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
server:
image: php:7.4-apache
image: php:8.0-apache
container_name: server
volumes:
- ./examples:/var/www/html
Expand Down
4 changes: 2 additions & 2 deletions examples/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-cli
FROM php:8.0-cli

RUN apt-get update \
&& apt-get install --no-install-recommends -y git \
Expand All @@ -13,7 +13,7 @@ RUN apt-get update \
&& echo 'extension=memcached.so' >> /usr/local/etc/php/php.ini \
&& yes '' | pecl install redis \
&& echo 'extension=redis.so' >> /usr/local/etc/php/php.ini \
&& yes '' | pecl install xdebug-2.9.0 \
&& yes '' | pecl install xdebug-3.1.5 \
&& echo 'zend_extension=xdebug.so' >> /usr/local/etc/php/php.ini \
&& yes '' | pecl install mongodb \
&& echo 'extension=mongodb.so' >> /usr/local/etc/php/php.ini \
Expand Down
11 changes: 11 additions & 0 deletions src/Ganesha/GaneshaHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,15 @@ private function avoidGaneshaOptionsPropagation(array $options): array

return $options;
}

/**
* {@inheritdoc}
*/
public function withOptions(array $options): static
{
$clone = clone $this;
$clone->client = $this->client->withOptions($options);

return $clone;
}
}
18 changes: 18 additions & 0 deletions tests/Ackintosh/Ganesha/GaneshaHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,24 @@ public function streamDelegatesToDecoratedInstance(): void
$client->stream($responses, $timeout);
}

/**
* @test
*/
public function buildWithOptions(): void
{
$client = $this->buildClient();
// Attach extra data to the request as default.
$clientWithOptions = $client->withOptions(['user_data' => 'test']);

$this->assertNotSame($client, $clientWithOptions);
$this->assertSame(\get_class($client), \get_class($clientWithOptions));

$response = $clientWithOptions->request('GET', 'http://server/server/index.php');

// Test that the extra data can be obtained.
$this->assertSame('test', $response->getInfo('user_data'));
}

/**
* @param MockResponse[] $responses
*/
Expand Down